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

Remove ErmBuffer::Parser.make_hash #49

Closed
wants to merge 1 commit into from

Conversation

vzvu3k6k
Copy link

@vzvu3k6k vzvu3k6k commented Apr 6, 2014

There is no need to make hashes of INDENT_KW, BACKDENT_KW,
BEGINDENT_KW, POSTCOND_KW and PRE_OPTIONAL_DO_KW.
Only include? is called for them.

There is no need to make hashes of INDENT_KW, BACKDENT_KW,
BEGINDENT_KW, POSTCOND_KW and PRE_OPTIONAL_DO_KW.
Only `include?` is called for them.
@zenspider
Copy link
Owner

Make_hash is there to make the include? call O(1) instead of O(n). Dunno if it matters for hashes this size tho. Benchmark it?

@vzvu3k6k
Copy link
Author

vzvu3k6k commented Apr 7, 2014

make the include? call O(1) instead of O(n)

Ah, I overlooked it...

I've benchmarked it and found it matters even for the smallest array. The difference is not so big (make_hash version of INDENT_KW is 1.77e-6 sec faster in each time on average in my env), but it may actually matters when processing a very big file. And as the cost of make_hash is vanishingly low (benchmark), I think it is better to leave it as it is.

Thank you for your trouble.

@vzvu3k6k vzvu3k6k closed this Apr 7, 2014
@vzvu3k6k vzvu3k6k mentioned this pull request May 13, 2014
Repository owner locked and limited conversation to collaborators Jan 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants