diff options
author | James Ko <jamesqko@gmail.com> | 2016-02-20 18:47:24 -0500 |
---|---|---|
committer | James Ko <jamesqko@gmail.com> | 2016-02-20 18:47:24 -0500 |
commit | b99e5c1638a7e909c918be313ef386b7d0ccb3c3 (patch) | |
tree | 149435d3ab298b85fceb9eaf4eb258d72e41dbd8 /src/mscorlib | |
parent | 2a694dd1cea6cd7d176893ad661041cd1dacf9a2 (diff) | |
download | coreclr-b99e5c1638a7e909c918be313ef386b7d0ccb3c3.tar.gz coreclr-b99e5c1638a7e909c918be313ef386b7d0ccb3c3.tar.bz2 coreclr-b99e5c1638a7e909c918be313ef386b7d0ccb3c3.zip |
Avoid string allocations in some Concat overloads
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/src/System/String.cs | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/mscorlib/src/System/String.cs b/src/mscorlib/src/System/String.cs index 72089b0785..f544fc9273 100644 --- a/src/mscorlib/src/System/String.cs +++ b/src/mscorlib/src/System/String.cs @@ -3237,20 +3237,19 @@ namespace System { (str2 == null ? 0 : str2.Length)); Contract.EndContractBlock(); - if (str0==null && str1==null && str2==null) { - return String.Empty; - } - - if (str0==null) { - str0 = String.Empty; + if (IsNullOrEmpty(str0)) + { + return Concat(str1, str2); } - if (str1==null) { - str1 = String.Empty; + if (IsNullOrEmpty(str1)) + { + return Concat(str0, str2); } - if (str2 == null) { - str2 = String.Empty; + if (IsNullOrEmpty(str2)) + { + return Concat(str0, str1); } int totalLength = str0.Length + str1.Length + str2.Length; @@ -3273,24 +3272,24 @@ namespace System { (str3 == null ? 0 : str3.Length)); Contract.EndContractBlock(); - if (str0==null && str1==null && str2==null && str3==null) { - return String.Empty; + if (IsNullOrEmpty(str0)) + { + return Concat(str1, str2, str3); } - if (str0==null) { - str0 = String.Empty; + if (IsNullOrEmpty(str1)) + { + return Concat(str0, str2, str3); } - if (str1==null) { - str1 = String.Empty; + if (IsNullOrEmpty(str2)) + { + return Concat(str0, str1, str3); } - if (str2 == null) { - str2 = String.Empty; - } - - if (str3 == null) { - str3 = String.Empty; + if (IsNullOrEmpty(str3)) + { + return Concat(str0, str1, str2); } int totalLength = str0.Length + str1.Length + str2.Length + str3.Length; |