diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-02-20 18:27:09 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-02-20 18:27:09 -0800 |
commit | a8e10c51b050917606b755b1f11f2a3dd9436dcf (patch) | |
tree | 44a0deb304c69a1d038bca8ce2e49b806ebdfede /src | |
parent | 77374b2d56441e924d0340a0c3da04e19a3d53dc (diff) | |
parent | b99e5c1638a7e909c918be313ef386b7d0ccb3c3 (diff) | |
download | coreclr-a8e10c51b050917606b755b1f11f2a3dd9436dcf.tar.gz coreclr-a8e10c51b050917606b755b1f11f2a3dd9436dcf.tar.bz2 coreclr-a8e10c51b050917606b755b1f11f2a3dd9436dcf.zip |
Merge pull request #3280 from jamesqo/patch-8
Avoid string allocations in some Concat overloads
Diffstat (limited to 'src')
-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; |