Clean up global variables namespace, save a few 100 bytes of flash#5368
Clean up global variables namespace, save a few 100 bytes of flash#5368softhack007 merged 6 commits intomainfrom
Conversation
these are not used anywhere else. Making them static avoid name conflicts, cleans up the global scope and in some cases allows for better optimization by the compiler.
WalkthroughRestricts linkage by converting many globals and helper functions to internal ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@netmindz is there a way to trigger a "manual" run of the usermods CI job on this PR branch? Just to be sure that no usermod breaks due to my changes. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Safe to make static * declared in fcn_declare.h, only used locally in one file * not declared in fcn_declare.h, only used locally
make bit array functions "static inline" -> better for optimization, saves some bytes because the compiler does not need to preserve a non-inline function copy for external references.
|
Flash Size
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
as suggested by the rabbit.
|
Flash Size - update
|
|
@coderabbitai please add the following to you regular review checks: When "C-style" functions or variables are added or modified, check if they are visible globally. If the function is not part of any global header file, suggest to:
|
|
Tip For best results, initiate chat on the files or code changes.
This will help maintain a clean global namespace and make the codebase more maintainable, as demonstrated by the benefits in this PR (-160 bytes flash on esp32dev, -492 bytes on nodemcuv2_160). 🐰✨ ✏️ Learnings added
🧠 Learnings used |
The normal build includes the usermods env that triggers every usermod with an esp32 so that should hopefully catch you changes as they don't relate to the compatibility of specific chips |
Reduces the scope of some variables and functions to "static" - if not used anywhere else.
Making them static avoids name conflicts, cleans up the global scope and allows for better optimization by the compiler.
We also save a few bytes, because the compiler does not need to keep copies of previously global functions.
Summary by CodeRabbit