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

Intern bools to avoid allocation on bool to interface{} #33

Merged
merged 1 commit into from
Oct 30, 2016

Conversation

prashantv
Copy link
Contributor

This doesn't affect any functionality, just reduces allocations and improves performance.

Affected benchmarks on master:

BenchmarkEvaluationNumericLiteral-8         20000000            79.6 ns/op         1 B/op          1 allocs/op
BenchmarkEvaluationLiteralModifiers-8       10000000           133 ns/op          16 B/op          2 allocs/op
BenchmarkEvaluationParameters-8             10000000           167 ns/op          17 B/op          2 allocs/op
BenchmarkEvaluationParametersModifiers-8     5000000           319 ns/op          40 B/op          4 allocs/op
BenchmarkComplexExpression-8                 3000000           482 ns/op          83 B/op          6 allocs/op
BenchmarkConstantRegexExpression-8           2000000           760 ns/op          48 B/op          7 allocs/op

Post-change:

BenchmarkEvaluationNumericLiteral-8         20000000            61.1 ns/op         0 B/op          0 allocs/op
BenchmarkEvaluationLiteralModifiers-8       20000000           117 ns/op           8 B/op          1 allocs/op
BenchmarkEvaluationParameters-8             10000000           147 ns/op          16 B/op          1 allocs/op
BenchmarkEvaluationParametersModifiers-8     5000000           287 ns/op          32 B/op          3 allocs/op
BenchmarkComplexExpression-8                 3000000           427 ns/op          80 B/op          3 allocs/op
BenchmarkConstantRegexExpression-8           2000000           681 ns/op          48 B/op          6 allocs/op

@Knetic
Copy link
Owner

Knetic commented Oct 30, 2016

Awesome! I love this change. Thanks for submitting it!

@Knetic Knetic merged commit 4e424a0 into Knetic:master Oct 30, 2016
@prashantv
Copy link
Contributor Author

Thanks for the library @Knetic

Just started playing with it today and it's been great!

@prashantv prashantv deleted the bool_intern branch October 30, 2016 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants