New tokenization & integer parsing helpers#17962
Merged
carlos-zamora merged 6 commits intomainfrom Oct 29, 2024
Merged
Conversation
DHowett
reviewed
Oct 3, 2024
src/inc/til/string.h
Outdated
| // Don't call operator*() twice per iteration. | ||
| // Since C++ has inflexible iterators we can't implement a split iterator efficiently: | ||
| // We essentially need a do-while loop but iterators only offer for() loop semantics. | ||
| // This forces us to either seek to the first token in the constructor and then again on |
Member
There was a problem hiding this comment.
qq: why prefer the one that makes it unsafe/hazardous to handle, instead of the one that makes it safe?
Member
Author
There was a problem hiding this comment.
An excellent point. I didn't even benchmark the two versions and what's not measured is not real. 😤
DHowett
approved these changes
Oct 3, 2024
|
|
||
| std::vector<DWORD> newRgbs; | ||
| for (auto&& part : parts) | ||
| for (const auto part : parts) |
Member
There was a problem hiding this comment.
auto&& should deduce const auto here, shouldn't it?
Member
Author
There was a problem hiding this comment.
It should, and I'm sure it does, but the linter complains (incorrectly), so I just changed it.
Member
Author
|
CI passed but ARM64 is being a drama queen. 😅 |
DHowett
approved these changes
Oct 10, 2024
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
zadjii-msft
approved these changes
Oct 21, 2024
DHowett
added a commit
to nukoseer/terminal
that referenced
this pull request
Dec 5, 2024
DHowett
pushed a commit
that referenced
this pull request
Apr 24, 2025
Reading through our existing patterns for integer parsing, I noticed that we'd be better off returning them as optionals. This also allowed me to improve the implementation to support integers all the way up to their absolute maximum/minimum. Furthermore, I noticed that `prefix_split` was unsound: If the last needle character was the last character in the remaining text, the remaining text would be updated to an empty string view. The caller would then have no idea if there's 1 more token left or if the string is truly empty. To solve this, this PR introduces an iterator class. This will allow it to be used in our VT parser code. (cherry picked from commit fa82730) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgZtkTk Service-Version: 1.22
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.
Reading through our existing patterns for integer parsing, I noticed
that we'd be better off returning them as optionals.
This also allowed me to improve the implementation to support integers
all the way up to their absolute maximum/minimum.
Furthermore, I noticed that
prefix_splitwas unsound:If the last needle character was the last character in the remaining
text, the remaining text would be updated to an empty string view.
The caller would then have no idea if there's 1 more token left
or if the string is truly empty.
To solve this, this PR introduces an iterator class. This will allow
it to be used in our VT parser code.