-
Notifications
You must be signed in to change notification settings - Fork 525
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
Command argument parsing improvements #255
Command argument parsing improvements #255
Conversation
* We can avoid allocating intermediary arrays and extra fixing now
* Also few other nits for speed
…piate * Avoid string allocation & avoid current thread culture lookup for equals * Switched some ToUpper to ToUpperInvariant too
* Avoid CurrentCulture lookup
* Also switch over to generic overloads, allows JIT to see what type is used
* We completely spanify these later, the calls got ugly
Missed one.
* Thanks github web editor
* StringComparison.Ordinal gets unrolled by JIT
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.
Excellent work! There are a lot of good changes in this PR. Thank you for working on this.
I have added a few comments with suggestions for improvement. Let’s address those points before merging. Once we’ve resolved the questions, I’ll be happy to perform another review.
* Comparisons strings to uppercase * Formatting adjustments * Few unnecessary using directives in the files which PR touches
* Makes it clear that the methods don't do extra "work"
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.
Great job on the code! Your thorough work is much appreciated. I believe we’re ready to merge this PR. Thank you for your valuable contribution! 🙌
Culture invariant parsing
Utf8Parser.TryParse
InvariantCulture
toParse
andToString
.CurrentCulture
lookups by usingToUpperInvariant
instead ofToUpper
StringComparison.OrdinalIgnoreCase
where we otherwise allocated uppercase string for string comparison. This equality comparison is also much faster as it doesn't care about cultures.StringComparison.Ordinal
where applicable for perf (it gets unrolled for constant inputs à laSequenceEquals
).StringComparison.OrdinalIgnoreCase
also gets unrolled for constants in .NET 8 but has to deal with some bit flipping for the case insensitivity.Enums
Enum.TryParse
instead of catching exceptions forEnum.Parse
, much more cheaper.Misc.
RespReadUtils
ArgSlice.FromPinnedSpan
IncrementIntegerOrFloat
logic.