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
[Immutablize#convert_value] reduce number of class comparisons #14234
Conversation
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting data on calls and timing
M1 MacPro with Ruby 3.1.2
|
Benchmarked on my personal laptop: https://gist.github.com/dafyddcrosby/00e8b526093b4e2819de48de30b088f5 I'm open to other ways of comparing the methods, but so far this does appear to be faster on multiple platforms and architectures |
Signed-off-by: David Crosby <dcrosby@fb.com>
13075a3
to
29f9fdb
Compare
Quality Gate passedIssues Measures |
@dafyddcrosby waiting on Verify just to be safe. |
Description
Noticed while doing #14226 (and orthogonal to it): on large amounts of Immutablize calls a decent amount of time is spent simply doing class comparisons for non-Hash/Array objects. We can reduce the comparisons by nearly half while retaining the prior optimization by checking for ImmutableArray/ImmutableMash after the object has already been identified as a Hash or an Array.
Related Issue
Types of changes
Checklist:
Gemfile.lock
has changed, I have used--conservative
to do it and included the full output in the Description above.