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

Make loadBg() more readable #3656

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Make loadBg() more readable #3656

merged 1 commit into from
Jan 8, 2024

Conversation

w00000dy
Copy link
Contributor

@w00000dy w00000dy commented Jan 7, 2024

In my quest to comprehend the functionality of the loadBg() function, I initially found it challenging. To facilitate my understanding, I annotated the code with comments and renamed variables for clarity. I would now like to share these modifications, hoping to simplify the code-reading process for future readers.

I also made some small improvements.
For example, the line img = null; is not strictly necessary.
The line img = null; is used to remove the reference to the img object, which can potentially allow the img object to be garbage collected sooner if there are no other references to it. However, in this case, the img object is created within the function and is not used outside of the function, so it will be garbage collected anyway once the function has finished executing.
This is why I removed this line.

Because of this change and the other small changes, we also saved a few bytes:
Before:

RAM:   [==        ]  24.7% (used 80968 bytes from 327680 bytes)
Flash: [========  ]  82.3% (used 1294253 bytes from 1572864 bytes)

Now:

RAM:   [==        ]  24.7% (used 80968 bytes from 327680 bytes)
Flash: [========  ]  82.3% (used 1294205 bytes from 1572864 bytes)

@blazoncek blazoncek merged commit 74e14a4 into wled:0_15 Jan 8, 2024
12 checks passed
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.

2 participants