Declare character code constants per file #13500
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR effectively reverts #13497 but preserves the naming improvements that makes the name of each constant consistent between files.
I noticed when benchmarking
segment
that objects access likeToken.OPEN_CURLY
made the function 25x slower (!) so we should at a minimum import all of the character codes directly instead of usingimport * as Token from ...
.I feel like since these aren't application-specific constants there's no harm in just redeclaring them in each file anyways —
BACKSLASH
is going to be0x5c
until the end of time, there's no risk that we have to update that value and now have to update it in more than one place. This also reduces the number of dependencies between files which is nice if we ever wanted to publish anything here as a separate package for any reason.