From f487d60b8d48ecbb4e61cfb158038addcd486b0b Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Fri, 25 Jan 2019 20:03:33 +0100 Subject: [PATCH] Skip rangecheck in string.EndsWith(char) (#22206) --- src/System.Private.CoreLib/shared/System/String.Comparison.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/String.Comparison.cs b/src/System.Private.CoreLib/shared/System/String.Comparison.cs index 5bae67b..c8f0d20 100644 --- a/src/System.Private.CoreLib/shared/System/String.Comparison.cs +++ b/src/System.Private.CoreLib/shared/System/String.Comparison.cs @@ -594,8 +594,8 @@ namespace System public bool EndsWith(char value) { - int thisLen = Length; - return thisLen != 0 && this[thisLen - 1] == value; + int lastPos = Length - 1; + return ((uint)lastPos < (uint)Length) && this[lastPos] == value; } // Determines whether two strings match. -- 2.7.4