Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Save code space by packing rgbw values into C union #7209

Merged
merged 3 commits into from
Nov 18, 2022

Conversation

jepler
Copy link
Member

@jepler jepler commented Nov 14, 2022

It's more efficient passing one register-sized structure than 4 arguments or 4 pointers; working on intermediate values of 'int' size is also more efficient in code size!

On raspberry pi pico w, this increased free flash space by +104 bytes. It also increased the speed of my testing animation very slightly, from 187fps to 189fps when run 'unthrottled'

Interestingly the code savings on BOARD=adafruit_neokey_trinkey_m0 is smaller, just 28 bytes. The difference is probably because samd21 boards were already optimized for space ("-Os" optimization) However, there is still a savings.

It's more efficient passing one register-sized structure than 4
arguments or 4 pointers; working on intermediate values of 'int' size
is also more efficient in code size!

On raspberry pi pico w, this increased free flash space by +104 bytes.
It also increased the speed of my testing animation very slightly, from
187fps to 189fps when run 'unthrottled'
@jepler jepler marked this pull request as ready for review November 14, 2022 15:30
@microdev1 microdev1 merged commit f637332 into adafruit:main Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants