Optimize array intersection functions for empty operands#22831
Open
mehmetcansahin wants to merge 1 commit into
Open
Optimize array intersection functions for empty operands#22831mehmetcansahin wants to merge 1 commit into
mehmetcansahin wants to merge 1 commit into
Conversation
Member
|
How does it affect performance for the negative case when none of the arrays is empty? |
Contributor
Author
|
@kamil-tekiela Thanks for the review. I reran the non-empty cases using 15 paired processes per scenario and repeated the measurements twice. For very small arrays, the overhead ranged from roughly 0.5% to 5%, corresponding to only a few nanoseconds per call. With 100 or 10,000 elements, the differences were generally around 1% or less and were not consistent between runs. Overall, the shortcut adds a small fixed cost to non-empty calls, which becomes negligible as the arrays grow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid unnecessary iteration when an empty operand guarantees an empty result for
array_intersect_key(),array_intersect_assoc(), andarray_uintersect_assoc().Includes regression tests covering validation and observable callback/warning behavior.