diff options
author | Marek Safar <marek.safar@gmail.com> | 2018-01-04 18:38:18 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-01-10 16:41:59 +0300 |
commit | 6aa4e4dac90f83424b35ce8f98a96090c9e76bbc (patch) | |
tree | a5070a225a14f62f6a4329da55d3e056d15666d4 /mcs/class/corlib | |
parent | e9913fdc487622073a0827f32f845b637163590d (diff) |
[corlib] Optimizes non-intrinsics version of string indexer code
Diffstat (limited to 'mcs/class/corlib')
-rw-r--r-- | mcs/class/corlib/ReferenceSources/String.cs | 15 | ||||
-rw-r--r-- | mcs/class/corlib/corlib.dll.sources | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/mcs/class/corlib/ReferenceSources/String.cs b/mcs/class/corlib/ReferenceSources/String.cs index e437cf804b5..de8634abd01 100644 --- a/mcs/class/corlib/ReferenceSources/String.cs +++ b/mcs/class/corlib/ReferenceSources/String.cs @@ -344,7 +344,7 @@ namespace System throw new ArgumentOutOfRangeException("indexB", Environment.GetResourceString("ArgumentOutOfRange_Index")); return CompareOrdinalUnchecked (strA, indexA, count, strB, indexB, count); - } + } unsafe String ReplaceInternal (char oldChar, char newChar) { @@ -491,7 +491,7 @@ namespace System while (p < end) { *p++ = paddingChar; } - } else { + } else { char *p = dest; char *end = p + totalWidth - m_stringLength; while (p < end) { @@ -758,5 +758,16 @@ namespace System return result; } + + [IndexerName ("Chars")] + public char this [int index] { + [IntrinsicAttribute] + get { + if ((uint)index >= m_stringLength) + ThrowHelper.ThrowIndexOutOfRangeException (); + + return Unsafe.Add (ref m_firstChar, index); + } + } } }
\ No newline at end of file diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index 821afe19aeb..b3e617eb133 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -1648,6 +1648,7 @@ corert/ThreadPoolBoundHandle.cs ../../../external/corert/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.cs +../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ITuple.cs |