From: James Ko Date: Thu, 18 Feb 2016 03:41:42 +0000 (-0500) Subject: Optimize String.Replace when the chars are the same X-Git-Tag: accepted/tizen/base/20180629.140029~5532^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=351091dcb99061d735cc2792139e737a8ead93dd;p=platform%2Fupstream%2Fcoreclr.git Optimize String.Replace when the chars are the same --- diff --git a/src/classlibnative/bcltype/stringnative.cpp b/src/classlibnative/bcltype/stringnative.cpp index 311be11..554e0b9 100644 --- a/src/classlibnative/bcltype/stringnative.cpp +++ b/src/classlibnative/bcltype/stringnative.cpp @@ -686,6 +686,15 @@ FCIMPL3(LPVOID, COMString::Replace, StringObject* thisRefUNSAFE, CLR_CHAR oldCha } //Perf: If no replacements required, return initial reference + + // Do it if the chars are the same... + + if ((WCHAR)oldChar == (WCHAR)newChar) + { + return thisRefUNSAFE; + } + + // Or if the old char isn't found. oldBuffer = thisRef->GetBuffer(); length = thisRef->GetStringLength();