ColorsPanel: for loop check condition simplify for optimize - #2041
ColorsPanel: for loop check condition simplify for optimize#2041GermanAizek wants to merge 1 commit into
Conversation
Access by index in array heavy operation vs check i index with const var LAST_COLORSCHEME
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo loops in ColorsPanel.c that iterate over color schemes were changed to use Changes
Sequence Diagram(s)Not applicable — this change is a simple loop-bound substitution with no new control flow or interactions to diagram. Estimated code review effort: Medium Related issues: None provided Related PRs: None provided Suggested labels: bug, cleanup Suggested reviewers: None provided Poem
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 |
|
@GermanAizek: Please show how much runtime / code that change saves. |
I can show assembler listing on -O3 using x86-64 instructions, I can calculate how many processor cycles are spent on this cycle, visually it will look like in this PR #2055 |
|
@fasterit indeed, checking for NULL makes the loop more vectorized and the compiler can optimize better for AVX instructions, I'll check other interesting loops for a similar case. But usually basic simplest loop is best optimized by C/C++ compilers when the |


@natoscott, isn't it easier to check each step in the loops with this PR condition?
Access by index in array heavy operation vs check i index with const var LAST_COLORSCHEME
Clion IDE have diff view Code and Assembly with compiler flags.
Out of interest, I can show how much less x86 instructions it should give on -O3.