From 38307ea0f4659a9aa062b576075be09551d196bc Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 5 Jan 2026 14:16:03 -0500 Subject: [PATCH] Use Array.Copy in Match.AddMatch --- .../src/System/Text/RegularExpressions/Match.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs index 36be3fceeca300..65e40dad2d4b4a 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs @@ -177,10 +177,7 @@ internal void AddMatch(int cap, int start, int len) { int[] oldmatches = matches[cap]; int[] newmatches = new int[capcount * 8]; - for (int j = 0; j < capcount * 2; j++) - { - newmatches[j] = oldmatches[j]; - } + Array.Copy(oldmatches, newmatches, capcount * 2); matches[cap] = newmatches; }