Skip to content
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

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

stephentoub
Copy link
Member

No description provided.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM, but the test failures are related:

image

FWIW This code was written for Unix, but these tests are run by default on Windows so you should be able to reproduce it locally.

@@ -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
Copy link
Member

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.

Copy link
Member Author

@stephentoub stephentoub Jun 21, 2024

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?

Copy link
Member

@adamsitnik adamsitnik left a 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 !

@stephentoub
Copy link
Member Author

/ba-g failures are known

@stephentoub stephentoub merged commit 78c82de into dotnet:main Jun 21, 2024
79 of 83 checks passed
@stephentoub stephentoub deleted the consolespanlookup branch June 21, 2024 13:57
rzikm pushed a commit to rzikm/dotnet-runtime that referenced this pull request Jun 24, 2024
* Use span-based dictionary lookup in System.Console

* Fix ctor
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants