Skip to content

Improve SendKeys performance - #3621

Merged
JeremyKuhne merged 2 commits into
dotnet:masterfrom
JeremyKuhne:sendkeys
Jul 22, 2020
Merged

JeremyKuhne merged 2 commits into
dotnet:masterfrom
JeremyKuhne:sendkeys

Conversation

@JeremyKuhne

@JeremyKuhne JeremyKuhne commented Jul 21, 2020 •

Copy link
Copy Markdown
Member

There were significantly more allocations in SendKeys than were necessary. This cuts them down by:

  1. Using structs instead of classes
  2. Using a generic queue
  3. Using stack allocated space to get key state

We hit the key state in Control as well. Also cleaned up the tracking of modifier keys a bit.

The first commit is just style cleanup. The second is the functional change.

@KlausLoeffelmann

Microsoft Reviewers: Open in CodeFlow

@JeremyKuhne
JeremyKuhne requested a review from a team as a code owner July 21, 2020 23:23
@ghost ghost assigned JeremyKuhne Jul 21, 2020
- SendKeys now uses a generic queue and structs to manage state.
- Change Get/SetKeyboardState so we can stackalloc the state array
- Clean up the modifer key state tracking
@JeremyKuhne

Copy link
Copy Markdown
Member Author

Missed the dangling thread static.

@RussKie RussKie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

with a nit

@RussKie RussKie added the enhancement Product code improvement that does NOT require public API changes/additions label Jul 22, 2020
@JeremyKuhne
JeremyKuhne merged commit 3afbbe5 into dotnet:master Jul 22, 2020
@ghost ghost added this to the 5.0 RC1 milestone Jul 22, 2020
@JeremyKuhne
JeremyKuhne deleted the sendkeys branch July 22, 2020 23:59
@ghost ghost locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement Product code improvement that does NOT require public API changes/additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants