Skip to content

Commit 701b219

Browse files
committed
remove additional array copy, IsIgnoredWord now works with string
1 parent c97ce0b commit 701b219

File tree

1 file changed

+2
-4
lines changed
  • src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents

1 file changed

+2
-4
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ private bool ScanTextSegment(SpellerInteropBase.ISpellerSegment textSegment, obj
943943
{
944944
TextMapCallbackData data = (TextMapCallbackData)o;
945945
SpellerInteropBase.ITextRange sTextRange = textSegment.TextRange;
946-
char[] word;
947946

948947
// Check if this segment falls outside the content range.
949948
// The region before/after the content is only for context --
@@ -962,8 +961,7 @@ private bool ScanTextSegment(SpellerInteropBase.ISpellerSegment textSegment, obj
962961
if (sTextRange.Length > 1) // Ignore single letter errors.
963962
{
964963
// Check if the segment has been marked "ignore" by the user.
965-
word = new char[sTextRange.Length];
966-
Array.Copy(data.TextMap.Text, sTextRange.Start, word, 0, sTextRange.Length);
964+
string word = new(data.TextMap.Text, sTextRange.Start, sTextRange.Length);
967965

968966
if (!IsIgnoredWord(word))
969967
{
@@ -1437,7 +1435,7 @@ private bool ExpandToWordBreakCallback(SpellerInteropBase.ISpellerSegment textSe
14371435
}
14381436

14391437
// Returns true if a user has tagged the specified word with "Ignore All".
1440-
private bool IsIgnoredWord(char[] word) => _ignoredWordsList?.BinarySearch(new string(word), _defaultComparer) >= 0;
1438+
private bool IsIgnoredWord(string word) => _ignoredWordsList?.BinarySearch(word, _defaultComparer) >= 0;
14411439

14421440
// Returns true if we have an engine capable of proofing the specified
14431441
// language.

0 commit comments

Comments
 (0)