Flash memory saving optimisations#52
Flash memory saving optimisations#52unwiredben merged 3 commits intosirleech:mastersirleech/Webduino:masterfrom ribbons:flash-savingCopy head branch name to clipboard
Conversation
Trim down the size of a couple of variables as they didn't need to be as large, clarify the type of some others, and change port from int to uint16_t to match EthernetServer.
Change the definition of the P() macro under the AVR architecture to store the strings in sections named after the variables. This allows unused strings to be removed by the linker, saving space in the flash memory. Also change the variable name for all but one of the instances of failMsg to give the maximum benefit from the above.
WebServer.h
Outdated
There was a problem hiding this comment.
Shouldn't you guard this definition with WEBDUINO_SUPRESS_SERVER_HEADER?
There was a problem hiding this comment.
Shouldn't you guard this definition with WEBDUINO_SUPRESS_SERVER_HEADER?
I did originally, but checked that once the string isn't referenced, the section containing it is removed by the linker (due to f95122d in this PR on AVR), so it doesn't use any space in flash.
Would you prefer me to wrap it with an #ifndef WEBDUINO_SUPRESS_SERVER_HEADER anyway for clarity?
There was a problem hiding this comment.
Actually, the main guard I want is #ifndef WEBDUINO_NO_IMPLEMENTATION which turns off definitions in the file... this lets a multi-file sketch include the .h file in multiple places, but only have one where it creates definitions. Your explanation of how the linker drops the section satisifies my other concern.
Modify the functions which send headers to re-use one string containing the server name instead of including it inline in all of the different headers.
|
Have updated this PR to move the definition of |
Flash memory saving optimisations
|
Merged in, thanks! |
These commits reduce flash memory usage by the library (by 426 bytes in my current project) by optimising the variables slightly, only storing strings that are used in flash and removing repetition of the server header value.