10000 Replace occurrences of params T[] with params ReadOnlySpan<T> where possible by h3xds1nz · Pull Request #9481 · dotnet/wpf · GitHub
[go: up one dir, main page]

Skip to content

Replace occurrences of params T[] with params ReadOnlySpan<T> where possible #9481

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

Merged
merged 11 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
convert CommandHelpers from params InputGesture[] to params ReadOnlyS…
…pan<InputGesture>
  • Loading branch information
h3xds1nz committed Jan 8, 2025
commit 1350b7d14202dfec082ae66ac61d68beffb401b9
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class CommandHelpers

internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler)
{
PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, null, null);
PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, null);
}

internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler,
Expand All @@ -39,7 +39,7 @@ internal static void RegisterCommandHandler(Type controlType, RoutedCommand comm
internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler,
CanExecuteRoutedEventHandler canExecuteRoutedEventHandler)
{
PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, canExecuteRoutedEventHandler, null);
PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, canExecuteRoutedEventHandler);
}

internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler,
Expand Down Expand Up @@ -90,7 +90,7 @@ internal static void RegisterCommandHandler(Type controlType, RoutedCommand comm

// 'params' based method is private. Call sites that use this bloat unwittingly due to implicit construction of the params array that goes into IL.
private static void PrivateRegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler,
CanExecuteRoutedEventHandler canExecuteRoutedEventHandler, params InputGesture[] inputGestures)
CanExecuteRoutedEventHandler canExecuteRoutedEventHandler, params ReadOnlySpan<InputGesture> inputGestures)
{
// Validate parameters
Debug.Assert(controlType != null);
Expand All @@ -102,12 +102,9 @@ private static void PrivateRegisterCommandHandler(Type controlType, RoutedComman
CommandManager.RegisterClassCommandBinding(controlType, new CommandBinding(command, executedRoutedEventHandler, canExecuteRoutedEventHandler));

// Create additional input binding for this command
if (inputGestures != null)
for (int i = 0; i < inputGestures.Length; i++)
{
for (int i = 0; i < inputGestures.Length; i++)
{
CommandManager.RegisterClassInputBinding(controlType, new InputBinding(command, inputGestures[i]));
}
CommandManager.RegisterClassInputBinding(controlType, new InputBinding(command, inputGestures[i]));
}
}

Expand Down
0