Skip to content

Use Enumerable#to_h to avoid extra allocation#6

Closed
the-spectator wants to merge 1 commit intoabachman:masterfrom
the-spectator:to-h
Closed

Use Enumerable#to_h to avoid extra allocation#6
the-spectator wants to merge 1 commit intoabachman:masterfrom
the-spectator:to-h

Conversation

@the-spectator
Copy link
Contributor

We can avoid extra allocation by directly calling #to_h on ENCODING.split('').each_with_index instead of first converting it to an array and then converting it to a hash.

This is not a Hot path for this library as constants are generated only on load. Please feel free to close the PR if this qualifies as a cosmetic change.

@colinbendell
Copy link

Further addressed in PR #10

@abachman
Copy link
Owner

closing in favor of #10, which changes the same location

@abachman abachman closed this May 29, 2024
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.

3 participants