Repository navigation
Optimize numeric token parsing - #202
Open
stevebauman wants to merge 1 commit into
Open
stevebauman wants to merge 1 commit into
stevebauman wants to merge 1 commit into
Conversation
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.
Numeric tokens are scanned twice when parsing IMAP responses. The tokenizer walks each digit to determine whether the value is a number, then walks those digits again to read it.
This uses
strspn()to scan digit runs and creates the number from the bytes already examined. Values such as123abcstill fall back to atom parsing, and digit runs can span buffer reads.This also fixes numbers returning an empty value at the end of the stream. The value is now copied before advancing clears the consumed buffer.
The following benchmarks compare this change against
masterafter #201, using PHP 8.4.27 and 35,798 synthetic responses per workload. The numeric-heavy workload fetches message numbers, UIDs, sizes, and modification sequences.The mixed-workload difference is small enough that more runs would be needed to distinguish it from measurement variation. The numeric-heavy workload shows a substantial improvement in both runs.
All 916 unit tests pass. Of 3,125 comparisons against the previous tokenizer, four differ because the numeric EOF bug is corrected. The remaining token and exception results match.
Refs #200.