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

refact: improve handling of arrays #1079

Merged
merged 7 commits into from
Aug 25, 2024
Merged

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented Aug 23, 2024

This PR improves working with arrays, by avoiding unnecessary temporary array allocations and providing specialized functions for filtering/iterating arrays which improves readability and avoids duplicate code.

@sebthom
Copy link
Member Author

sebthom commented Aug 23, 2024

@rubenporras I did not want to name the empty arrays as verbose as EMPTY_BYTE_ARRAY so I went with ZERO_BYTES but would I actually prefer to name them even shorter like NO_BYTES, NO_OBJECTS but I am unsure if this could result in misunderstandings when reading the code. WDYT?

@rubenporras
Copy link
Contributor

@rubenporras I did not want to name the empty arrays as verbose as EMPTY_BYTE_ARRAY so I went with ZERO_BYTES but would I actually prefer to name them even shorter like NO_BYTES, NO_OBJECTS but I am unsure if this could result in misunderstandings when reading the code. WDYT?

I think that if you know that it is beneficial to reuse empty arrays to reduce creation/garbage collection, all names are fine, and otherwise you will not understand it.

What about choosing the names you like and commenting the class ArrayUtil with the explanation of the pattern?

@sebthom sebthom changed the title perf: reuse empty arrays refact: improve handling of arrays Aug 24, 2024
@sebthom sebthom force-pushed the empty-arrays branch 2 times, most recently from a0320af to c419c2c Compare August 25, 2024 11:55
@sebthom sebthom merged commit 2d89929 into eclipse:main Aug 25, 2024
6 checks passed
@sebthom sebthom deleted the empty-arrays branch August 25, 2024 12:18
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