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

Use Hash#key? instead of Hash#keys.any? #201

Merged
merged 1 commit into from
May 3, 2019

Conversation

ashmaroli
Copy link
Member

Hash#key? is a lot faster than Hash#keys.any?

Warming up --------------------------------------
           keys.any?    38.835k i/100ms
                key?    93.048k i/100ms
Calculating -------------------------------------
           keys.any?    573.498k (A± 1.3%) i/s -      2.874M in   5.011842s
                key?      2.883M (A± 1.7%) i/s -     14.422M in   5.003596s

Comparison:
                key?:  2883339.1 i/s
           keys.any?:   573498.4 i/s - 5.03x  slower

@ashmaroli ashmaroli requested review from benbalter and a team May 3, 2019 14:06
Copy link
Contributor

@benbalter benbalter left a comment

Choose a reason for hiding this comment

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

Nice catch!

@ashmaroli
Copy link
Member Author

@jekyllbot: merge +fix

@jekyllbot jekyllbot merged commit 873f537 into jekyll:master May 3, 2019
jekyllbot added a commit that referenced this pull request May 3, 2019
@ashmaroli ashmaroli deleted the hash-has-key-check branch May 3, 2019 16:05
@jekyll jekyll locked and limited conversation to collaborators May 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants