From cae5cefd4ddbf3da844f8ffb4f3e06430f38a338 Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Thu, 3 Oct 2024 10:51:57 +0200 Subject: [PATCH] Use string.Equals over string.Compare for improved performance (#9724) --- .../src/WindowsBase/MS/Internal/ContentType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs index 925ed85ca2a..8b62d6c2657 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs @@ -258,8 +258,8 @@ internal bool AreTypeAndSubTypeEqual(ContentType contentType, bool allowParamete // safe comparison because the _type and _subType strings have been restricted to // ASCII characters, digits, and a small set of symbols. This is not a safe comparison // for the broader set of strings that have not been restricted in the same way. - result = (String.Compare(_type, contentType.TypeComponent, StringComparison.OrdinalIgnoreCase) == 0 && - String.Compare(_subType, contentType.SubTypeComponent, StringComparison.OrdinalIgnoreCase) == 0); + result = string.Equals(_type, contentType.TypeComponent, StringComparison.OrdinalIgnoreCase) && + string.Equals(_subType, contentType.SubTypeComponent, StringComparison.OrdinalIgnoreCase); } return result; }