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

protoparse: make lexer do fewer allocations #251

merged 2 commits into from Jul 26, 2019


Copy link

@jhump jhump commented Jul 26, 2019

This hopefully removes a lot of the heap-allocations happening in the lexer. The comment and SourcePos structs were small, and we ended up allocating a lot of the latter. So hopefully copying them around will be more efficient (certainly less load on allocator/GC).

This also removes some of the lambdas in the main Lex method so the compiler doesn't need to heap-allocate local variables. Instead, the necessary state was added as fields to the protoLex struct, and the lambdas were promoted to methods on protoLex.

@jhump jhump changed the title protoparse: make lexer more efficient protoparse: make lexer do fewer allocations Jul 26, 2019
@jhump jhump merged commit 900b929 into master Jul 26, 2019
@jhump jhump deleted the jh/make-lexer-more-efficient branch July 26, 2019 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant