-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use span-based dictionary lookup in System.Console #103742
Conversation
Tagging subscribers to this area: @dotnet/area-system-console |
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.
src/libraries/System.Console/src/System/TerminalFormatStrings.cs
Outdated
Show resolved
Hide resolved
@@ -62,14 +62,15 @@ private static bool TryParseTerminalInputSequence(char[] buffer, TerminalFormatS | |||
return false; | |||
} | |||
|
|||
Dictionary<ReadOnlyMemory<char>, ConsoleKeyInfo> terminfoDb = terminalFormatStrings.KeyFormatToConsoleKey; // the most important source of truth | |||
Dictionary<string, ConsoleKeyInfo>.AlternateLookup<ReadOnlySpan<char>> terminfoDb = // the most important source of truth |
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.
Shouldn't we be caching the alternate lookup struct somewhere? This is incurring a runtime type test against a generic interface which presumably would add up assuming this is a performance sensitive application.
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.
Didn't seem worth trying to avoid the overhead of a cast as part of the handling of a user's key strokes?
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.
LGTM, thank you @stephentoub !
/ba-g failures are known |
* Use span-based dictionary lookup in System.Console * Fix ctor
No description provided.