Make the reflect path parser utf-8-unaware#9371
Merged
Merged
Conversation
Contributor
|
Example |
alice-i-cecile
approved these changes
Aug 20, 2023
a1f8c4a to
66b44e6
Compare
soqb
approved these changes
Aug 25, 2023
soqb
left a comment
Contributor
There was a problem hiding this comment.
not a huge fan of the unsafe, but it's reasonably trivial and i trust the performance improvements are compelling!
This works because the delimiter symbols '.[]#' are all ASCII, and the parser really only needs to care about delimiters, so we can avoid the overhead of handling properly at all steps utf-8 strings. This is a major improvement when comparing to the previous parser. 1. `access_following` and `next_token` now inline in PathParser::next 2. Benchmarking show a 20% performance increase
auto-merge was automatically disabled
August 25, 2023 15:50
Head branch was pushed to by a user without write access
6c0ccc4 to
f512e79
Compare
Contributor
Author
|
ooops. Well I rebased to latest HEAD, expecting to fix CI. But instead I disabled auto-merge. |
43 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Objective
All delimiter symbols used by the path parser are ASCII, this means we can entirely ignore UTF8 handling. This may improve performance.
Solution
Instead of storing the path as an
&str+ the parser offset, and reading the path using&self.path[self.offset..], we store the parser state in a&[u8]. This allows two optimizations:&self.path[self.offset..]&[u8]'s reference metadata, and is assumed valid by the compiler.This is a major improvement when comparing to the previous parser.
access_followingandnext_tokennow inline inPathParser::nextPlease note that while we ignore UTF-8 handling, utf-8 is still supported. This is because we only handle "at the edges" what happens exactly before and after a recognized
SYMBOL. utf-8 is handled transparently beyond that.