Skip to content

Conversation

@jeremy-visionaid
Copy link
Contributor

No description provided.

@davidortinau davidortinau requested a review from Copilot May 27, 2025 18:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@davidortinau davidortinau requested a review from Copilot May 27, 2025 18:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to reduce memory allocations by caching enum values and replacing list accumulations with bitwise operations across keyboard modifier and key extension methods. Key changes include:

  • Using cached static readonly enum arrays in both iOS and Windows extension classes.
  • Refactoring methods to accumulate flags via bitwise OR instead of creating temporary lists.
  • Converting KeyboardKeysExtensions to a partial class to support platform-specific implementations.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
KeyboardModifiersExtensions.iOS.cs Replaces list aggregation with bitwise OR and uses cached enum values for KeyboardModifiers and UIKeyModifierFlags.
KeyboardKeysExtensions.iOS.cs Uses cached enum values for KeyboardKeys and UIKeyboardHidUsage; class converted to partial.
KeyboardKeysExtensions.cs Introduces a shared cached KeyboardKeysValues array for use by partial classes.
KeyboardKeysExtensions.Windows.cs Refactors to use cached enum values and aligns with partial class design for platform consistency.
Comments suppressed due to low confidence (2)

src/Plugin.Maui.KeyListener/KeyboardKeysExtensions.iOS.cs:8

  • [nitpick] Consider renaming 'UIKeyboardHidUsages' to 'UIKeyboardHidUsageValues' for consistency with similar naming conventions used in other extension files.
static readonly UIKeyboardHidUsage[] UIKeyboardHidUsages = Enum.GetValues<UIKeyboardHidUsage>();

src/Plugin.Maui.KeyListener/KeyboardModifiersExtensions.iOS.cs:6

  • [nitpick] Consider reviewing if 'KeyboardModifiersExtensions' should also be declared as partial for consistency with the partial classes in other keyboard extensions.
internal static class KeyboardModifiersExtensions

@davidortinau davidortinau merged commit f12e339 into davidortinau:main May 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants