Added StringPattern and made Automaton no longer borrow the query #618
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.
Short description
The
Automaton
struct borrowed the source query, which also caused theEngine to carry the query's lifetime with it. The actual data being borrowed
were the
JsonString
values for member transitions.In preparation for #117 we remove the borrowed
JsonString
and replace itwith
StringPattern
. For UTF-8 theStringPattern
will be a more complexstruct that precomputes some stuff for efficient matching later.
For now, it's a thin wrapper over a
JsonString
.During construction we may create many transitions over the same pattern.
To reduce the size of the automaton we cache the patterns and put them
into an
Rc
. This may get optimised later to instead use some kind ofinline storage, but it's unlikely to actually matter. I ran the benchmarks
and saw no measurable difference between the previous version and this one.
Issue
Resolves: #613
Checklist
All of these should be ticked off before you submit the PR.
just verify
locally and it succeeded.