From b9424710ae7a07e025b00bef7d189e2aa42fbe7c Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Sun, 12 Nov 2023 14:27:07 -0500 Subject: [PATCH] fix: Don't iterate with every parameter --- Remora.Commands/Trees/Nodes/CommandNode.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Remora.Commands/Trees/Nodes/CommandNode.cs b/Remora.Commands/Trees/Nodes/CommandNode.cs index e20876c..4d8d133 100644 --- a/Remora.Commands/Trees/Nodes/CommandNode.cs +++ b/Remora.Commands/Trees/Nodes/CommandNode.cs @@ -201,14 +201,13 @@ public bool TryBind var boundParameters = new List(); while (parametersToCheck.Count > 0) { + // Because the current enumerator might be invalid or ended, we'll fix up the key-value pair here + var current = enumerator.MoveNext() + ? enumerator.Current + : KeyValuePair.Create(string.Empty, (IReadOnlyList)Array.Empty()); var matchedParameters = new List(); foreach (var parameterToCheck in parametersToCheck) { - // Because the current enumerator might be invalid or ended, we'll fix up the key-value pair here - var current = enumerator.MoveNext() - ? enumerator.Current - : KeyValuePair.Create(string.Empty, (IReadOnlyList)Array.Empty()); - if (!parameterToCheck.Matches(current, out var isFatal, searchOptions)) { if (isFatal)