Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/String.Manipulation.cs')
-rw-r--r--src/System.Private.CoreLib/shared/System/String.Manipulation.cs42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
index 9ea2ef0f0..3da96bb3b 100644
--- a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
+++ b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
@@ -897,7 +897,7 @@ namespace System
return result;
}
- // a remove that just takes a startindex.
+ // a remove that just takes a startindex.
public string Remove(int startIndex)
{
if (startIndex < 0)
@@ -919,16 +919,12 @@ namespace System
switch (comparisonType)
{
case StringComparison.CurrentCulture:
- return ReplaceCore(oldValue, newValue, CultureInfo.CurrentCulture, CompareOptions.None);
-
case StringComparison.CurrentCultureIgnoreCase:
- return ReplaceCore(oldValue, newValue, CultureInfo.CurrentCulture, CompareOptions.IgnoreCase);
+ return ReplaceCore(oldValue, newValue, CultureInfo.CurrentCulture, GetCaseCompareOfComparisonCulture(comparisonType));
case StringComparison.InvariantCulture:
- return ReplaceCore(oldValue, newValue, CultureInfo.InvariantCulture, CompareOptions.None);
-
case StringComparison.InvariantCultureIgnoreCase:
- return ReplaceCore(oldValue, newValue, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase);
+ return ReplaceCore(oldValue, newValue, CultureInfo.InvariantCulture, GetCaseCompareOfComparisonCulture(comparisonType));
case StringComparison.Ordinal:
return Replace(oldValue, newValue);
@@ -1140,7 +1136,7 @@ namespace System
int count = replacementIdx - thisIdx;
if (count != 0)
{
- this.AsSpan().Slice(thisIdx, count).CopyTo(dstSpan.Slice(dstIdx));
+ this.AsSpan(thisIdx, count).CopyTo(dstSpan.Slice(dstIdx));
dstIdx += count;
}
thisIdx = replacementIdx + oldValueLength;
@@ -1152,7 +1148,7 @@ namespace System
// Copy over the final non-matching portion at the end of the string.
Debug.Assert(this.Length - thisIdx == dstSpan.Length - dstIdx);
- this.AsSpan().Slice(thisIdx).CopyTo(dstSpan.Slice(dstIdx));
+ this.AsSpan(thisIdx).CopyTo(dstSpan.Slice(dstIdx));
return dst;
}
@@ -1252,7 +1248,7 @@ namespace System
return new string[] { this };
}
- string[] result = omitEmptyEntries
+ string[] result = omitEmptyEntries
? SplitOmitEmptyEntries(sepList, default, 1, count)
: SplitKeepEmptyEntries(sepList, default, 1, count);
@@ -1266,7 +1262,7 @@ namespace System
return SplitInternal(separator ?? string.Empty, null, int.MaxValue, options);
}
- public string[] Split(string separator, Int32 count, StringSplitOptions options = StringSplitOptions.None)
+ public string[] Split(string separator, int count, StringSplitOptions options = StringSplitOptions.None)
{
return SplitInternal(separator ?? string.Empty, null, count, options);
}
@@ -1276,7 +1272,7 @@ namespace System
return SplitInternal(null, separator, int.MaxValue, options);
}
- public string[] Split(string[] separator, Int32 count, StringSplitOptions options)
+ public string[] Split(string[] separator, int count, StringSplitOptions options)
{
return SplitInternal(null, separator, count, options);
}
@@ -1317,7 +1313,7 @@ namespace System
{
return SplitInternal(separator, count, options);
}
-
+
Span<int> sepListInitialSpan = stackalloc int[StackallocIntBufferSizeLimit];
var sepListBuilder = new ValueListBuilder<int>(sepListInitialSpan);
@@ -1327,14 +1323,14 @@ namespace System
MakeSeparatorList(separators, ref sepListBuilder, ref lengthListBuilder);
ReadOnlySpan<int> sepList = sepListBuilder.AsSpan();
ReadOnlySpan<int> lengthList = lengthListBuilder.AsSpan();
-
+
// Handle the special case of no replaces.
if (sepList.Length == 0)
{
return new string[] { this };
}
- string[] result = omitEmptyEntries
+ string[] result = omitEmptyEntries
? SplitOmitEmptyEntries(sepList, lengthList, 0, count)
: SplitKeepEmptyEntries(sepList, lengthList, 0, count);
@@ -1357,7 +1353,7 @@ namespace System
return new string[] { this };
}
- string[] result = options == StringSplitOptions.RemoveEmptyEntries
+ string[] result = options == StringSplitOptions.RemoveEmptyEntries
? SplitOmitEmptyEntries(sepList, default, separator.Length, count)
: SplitKeepEmptyEntries(sepList, default, separator.Length, count);
@@ -1402,15 +1398,15 @@ namespace System
}
- // This function will not keep the Empty string
+ // This function will not keep the Empty string
private string[] SplitOmitEmptyEntries(ReadOnlySpan<int> sepList, ReadOnlySpan<int> lengthList, int defaultLength, int count)
{
Debug.Assert(count >= 2);
int numReplaces = sepList.Length;
- // Allocate array to hold items. This array may not be
- // filled completely in this function, we will create a
+ // Allocate array to hold items. This array may not be
+ // filled completely in this function, we will create a
// new array and copy string references to that new array.
int maxItems = (numReplaces < count) ? (numReplaces + 1) : count;
string[] splitStrings = new string[maxItems];
@@ -1557,7 +1553,7 @@ namespace System
if (this[i] == separator[0] && currentSepLength <= Length - i)
{
if (currentSepLength == 1
- || CompareOrdinal(this, i, separator, 0, currentSepLength) == 0)
+ || this.AsSpan(i, currentSepLength).SequenceEqual(separator))
{
sepListBuilder.Append(i);
i += currentSepLength - 1;
@@ -1571,7 +1567,7 @@ namespace System
/// </summary>
/// <param name="separators">separator strngs</param>
/// <param name="sepListBuilder"><see cref="ValueListBuilder{T}"/> for separator indexes</param>
- /// <param name="lengthListBuilder"><see cref="ValueListBuilder{T}"/> for separator length values</param>
+ /// <param name="lengthListBuilder"><see cref="ValueListBuilder{T}"/> for separator length values</param>
private void MakeSeparatorList(string[] separators, ref ValueListBuilder<int> sepListBuilder, ref ValueListBuilder<int> lengthListBuilder)
{
Debug.Assert(separators != null && separators.Length > 0, "separators != null && separators.Length > 0");
@@ -1591,7 +1587,7 @@ namespace System
if (this[i] == separator[0] && currentSepLength <= Length - i)
{
if (currentSepLength == 1
- || CompareOrdinal(this, i, separator, 0, currentSepLength) == 0)
+ || this.AsSpan(i, currentSepLength).SequenceEqual(separator))
{
sepListBuilder.Append(i);
lengthListBuilder.Append(currentSepLength);
@@ -1702,7 +1698,7 @@ namespace System
}
// Trims the whitespace from both ends of the string. Whitespace is defined by
- // Char.IsWhiteSpace.
+ // char.IsWhiteSpace.
//
public string Trim() => TrimWhiteSpaceHelper(TrimType.Both);