esp8266-fastled-webserver icon indicating copy to clipboard operation
esp8266-fastled-webserver copied to clipboard

Fields: Have each type independently serialize

Open henrygab opened this issue 4 years ago • 0 comments

Originally posted by @tobi01001 in https://github.com/jasoncoon/esp8266-fastled-webserver/pull/216#discussion_r757550079

In convertToJson(), the request is to have each unique Field_t serialization handled in the switch statement directly, rather than code multiple if statements that each run code that is common to a random subset of the types.

This will help make the code easier to understand, which reduces bugs.

On platforms that use F-Strings (ESP8266, AVR), there will be a small cost that cannot be optimized, due to the optimizer's inability to consolidate F-strings. On platforms with flat memory model (ESP32, most ARM based mcu), it is expected that the compiler will consolidate common code paths more efficiently than human hand optimization.

henrygab avatar Nov 28 '21 02:11 henrygab