Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WString] Reduce build size by implementing flash string calls in .cpp #8106

Merged
merged 2 commits into from
Sep 4, 2021

Commits on Jun 7, 2021

  1. [WString] Reduce build size by implementing flash string calls in .cpp

    A function called with a flash string, which only has an implementation with `const String&` as argument will be compiled as if it is called with a `String` constructor wrapped around it.
    
    For example this implementation in the .h file:
    ```c++
    bool startsWith(const __FlashStringHelper *prefix) const {
                return this->startsWith(String(prefix));
    }
    ```
    
    This is completely useless as the compiler will generate exactly the same code with or without this function implementation in the .h file.
    However if we move the implementation to the .cpp file, this conversion to `String` is only added once in the compiled binary.
    In my own project I already managed to shrink the largest (ESP32) build by more than 70k in size (!!) by just adding extra function calls with the conversion in the .cpp file.
    This PR is just a simple optimisation which already shrinks a very small build of my project by almost 3k in build size.  (custom_beta_ESP8266_4M1M PIO env of ESPEasy)
    
    ```
    Flash: [========  ]  82.5% (used 862137 bytes from 1044464 bytes)
    Flash: [========  ]  82.3% (used 859545 bytes from 1044464 bytes)
    ```
    
    Larger builds may benefit even more.
    TD-er committed Jun 7, 2021
    Configuration menu
    Copy the full SHA
    fe04afb View commit details
    Browse the repository at this point in the history

Commits on Sep 4, 2021

  1. Configuration menu
    Copy the full SHA
    12f7247 View commit details
    Browse the repository at this point in the history