projects
/
platform
/
upstream
/
coreclr.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
89396ee
)
Optimize String.Replace when the chars are the same
author
James Ko
<jamesqko@gmail.com>
Thu, 18 Feb 2016 03:41:42 +0000
(22:41 -0500)
committer
James Ko
<jamesqko@gmail.com>
Thu, 18 Feb 2016 03:41:42 +0000
(22:41 -0500)
src/classlibnative/bcltype/stringnative.cpp
patch
|
blob
|
history
diff --git
a/src/classlibnative/bcltype/stringnative.cpp
b/src/classlibnative/bcltype/stringnative.cpp
index
311be11
..
554e0b9
100644
(file)
--- 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();