-
Notifications
You must be signed in to change notification settings - Fork 9k
New tokenization & integer parsing helpers #17962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: why prefer the one that makes it unsafe/hazardous to handle, instead of the one that makes it safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An excellent point. I didn't even benchmark the two versions and what's not measured is not real. 😤
|
|
||
| std::vector<DWORD> newRgbs; | ||
| for (auto&& part : parts) | ||
| for (const auto part : parts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto&& should deduce const auto here, shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, and I'm sure it does, but the linter complains (incorrectly), so I just changed it.
|
CI passed but ARM64 is being a drama queen. 😅 |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
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.