Skip to content

container: Improve TreeMap::forEach#231

Merged
MonsterDruide1 merged 3 commits intoopen-ead:masterfrom
MonsterDruide1:improve-treemap-foreach
Jan 20, 2026
Merged

container: Improve TreeMap::forEach#231
MonsterDruide1 merged 3 commits intoopen-ead:masterfrom
MonsterDruide1:improve-treemap-foreach

Conversation

@MonsterDruide1
Copy link
Contributor

@MonsterDruide1 MonsterDruide1 commented Dec 14, 2025

As suggested by @aboood40091 (#227 (comment)), our implementation of TreeMap::forEach can be slightly simplified to avoid an explicit loop and use recursion instead. Only change from his suggestion: node->mRight must be fetched before fun(node) is called to match the existing behaviour and keep existing functions matched.


This change is Reviewable

@aboood40091
Copy link
Contributor

Could it be that they original saved left and right in variables at the beginning of the function instead? Does that still match?

@MonsterDruide1
Copy link
Contributor Author

@aboood40091 No, that does not match. I can move left = node->mLeft before the first usage and re-use that temporary, but mRight needs to be ldred between forEach(left, fun); and fun(node); - that ldr instruction is just after the bl of forEach, and quite a bit before the blr of fun(node);.

@MonsterDruide1
Copy link
Contributor Author

@aboood40091 Any other comments?

@aboood40091
Copy link
Contributor

All good, and I'll let you decide if you want to use a temporary for left too.

@MonsterDruide1
Copy link
Contributor Author

Yes, that's still not a bad idea. Adjusted accordingly.

Copy link
Contributor

@german77 german77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@german77 partially reviewed 1 file.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @MonsterDruide1).

@MonsterDruide1 MonsterDruide1 merged commit 2a5e03f into open-ead:master Jan 20, 2026
3 of 4 checks passed
@MonsterDruide1 MonsterDruide1 deleted the improve-treemap-foreach branch January 20, 2026 22:01
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.

3 participants