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

WIP faster hash building #6

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

jhawthorn
Copy link
Owner

WIP

It's faster to buffer items in a (C) array before creating a hash from them. Partly because this avoids the cost in Ruby of building a ar_table before it is converted to an st_table once the hash goes beyond 8 elements.

I don't believe this has been tested sufficiently yet.

hash_buffer_idx--;
}

VALUE hash = rb_hash_new_capa(hash_buffer_idx / 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added rb_hash_new_capa in 3.2, we'd likely need a fallback for older rubies.

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