Skip to content

Commit

Permalink
PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::S…
Browse files Browse the repository at this point in the history
…ubsequence(): Changed to using Arrays.Copy() to copy the array instead of a for loop.
  • Loading branch information
NightOwl888 committed Jan 19, 2024
1 parent 85458d3 commit 8c3af72
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ public ICharSequence Subsequence(int startIndex, int length)
throw new ArgumentOutOfRangeException(nameof(length), $"Index and length must refer to a location within the string. For example {nameof(startIndex)} + {nameof(length)} <= {nameof(Length)}.");

char[] result = new char[length];
for (int i = 0, j = startIndex; i < length; i++, j++)
result[i] = termBuffer[j];

Arrays.Copy(termBuffer, startIndex, result, 0, length);
return new CharArrayCharSequence(result);
}

Expand Down

0 comments on commit 8c3af72

Please sign in to comment.