From 4f9f766129e54e3f5a99285eea86184acdf28a2a Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Fri, 7 Jun 2024 19:30:35 +0200 Subject: [PATCH] lets be about 0.6ns faster by actually using contains for contains --- .../System/Windows/Documents/FixedTextBuilder.cs | 2 +- .../System/Windows/Documents/TextPointerBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedTextBuilder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedTextBuilder.cs index 6d3ddb4b1fb..5f62fd2086d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedTextBuilder.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedTextBuilder.cs @@ -102,7 +102,7 @@ internal static bool AlwaysAdjacent(CultureInfo ci) '\x00AD' // Soft-Hyphen ]; - internal static bool IsHyphen(char target) => HyphenSet.IndexOf(target) > -1; + internal static bool IsHyphen(char target) => HyphenSet.Contains(target); // Space that was used in the heuristic algorithm. internal static bool IsSpace(char target) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextPointerBase.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextPointerBase.cs index 8079770ca56..8d335bf8383 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextPointerBase.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextPointerBase.cs @@ -640,7 +640,7 @@ internal static bool IsNextToPlainLineBreak(ITextPointer thisPosition, LogicalDi internal static ReadOnlySpan NextLineCharacters => ['\n', '\r', '\v', '\f', '\u0085' /*NEL*/, '\u2028' /*LS*/, '\u2029' /*PS*/]; // Returns true if a specified char matches the Unicode definition of "newline". - internal static bool IsCharUnicodeNewLine(char ch) => NextLineCharacters.IndexOf(ch) > -1; + internal static bool IsCharUnicodeNewLine(char ch) => NextLineCharacters.Contains(ch); /// /// Returns true if the position is adjacent to a LineBreak element,