Closed softhack007 closed 2 years ago
Thank you for the insight!
As I am readying 2D (and audioreactive as a usermod) it may be a good time to revisit the use of uint8_t and uint16_t througout WLED.
Most of the uint8_t
and uint16_t
uses in FX.cpp were replace by int
or size_t
which use CPU native size and should be optimised.
Other cases are not executed too often and can be dealt with at a later time if at all.
As a general improvement when speed matters, use
_fast_
versions of fixed width integers. Operations on these types are usually faster than using the "exact" types likeuint8_t
etc. For example, when doing an operation on uint8_t, the compiler may need additional instructions for loading/storing from unaligned (odd) addresses, and extra operations to ensure that computation results remain in 8bit - like& 0xFF
after each addition.The fast types are:
These are the "fastest signed/unsigned integer type with width of at least 8, 16, and 32 bits respectively".
https://en.cppreference.com/w/c/types/integer
https://stackoverflow.com/questions/10338966/the-use-of-int8-t-on-some-small-values-on-32bit-machine-is-useless-optimization