Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
AsReadOnlySpan -> AsSpan rename to fix build breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Feb 23, 2018
1 parent a79398e commit 22f1bc0
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 66 deletions.
10 changes: 5 additions & 5 deletions src/mscorlib/shared/System/Boolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public bool TryFormat(Span<char> destination, out int charsWritten)
{
string s = m_value ? TrueLiteral : FalseLiteral;

if (s.AsReadOnlySpan().TryCopyTo(destination))
if (s.AsSpan().TryCopyTo(destination))
{
charsWritten = s.Length;
return true;
Expand Down Expand Up @@ -181,7 +181,7 @@ public int CompareTo(Boolean value)
public static Boolean Parse(String value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
return Parse(value.AsReadOnlySpan());
return Parse(value.AsSpan());
}

public static bool Parse(ReadOnlySpan<char> value) =>
Expand All @@ -197,19 +197,19 @@ public static Boolean TryParse(String value, out Boolean result)
return false;
}

return TryParse(value.AsReadOnlySpan(), out result);
return TryParse(value.AsSpan(), out result);
}

public static bool TryParse(ReadOnlySpan<char> value, out bool result)
{
ReadOnlySpan<char> trueSpan = TrueLiteral.AsReadOnlySpan();
ReadOnlySpan<char> trueSpan = TrueLiteral.AsSpan();
if (StringSpanHelpers.Equals(trueSpan, value, StringComparison.OrdinalIgnoreCase))
{
result = true;
return true;
}

ReadOnlySpan<char> falseSpan = FalseLiteral.AsReadOnlySpan();
ReadOnlySpan<char> falseSpan = FalseLiteral.AsSpan();
if (StringSpanHelpers.Equals(falseSpan, value, StringComparison.OrdinalIgnoreCase))
{
result = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Append(T item)
_pos = pos + 1;
}

public ReadOnlySpan<T> AsReadOnlySpan()
public ReadOnlySpan<T> AsSpan()
{
return _span.Slice(0, _pos);
}
Expand Down
18 changes: 9 additions & 9 deletions src/mscorlib/shared/System/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ public static byte ToByte(String value, int fromBase)
return 0;
}

int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
if (r < Byte.MinValue || r > Byte.MaxValue)
ThrowByteOverflowException();
return (byte)r;
Expand All @@ -2221,7 +2221,7 @@ public static sbyte ToSByte(String value, int fromBase)
return 0;
}

int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1);
int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1);
if (fromBase != 10 && r <= Byte.MaxValue)
return (sbyte)r;

Expand All @@ -2246,7 +2246,7 @@ public static short ToInt16(String value, int fromBase)
return 0;
}

int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2);
int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2);
if (fromBase != 10 && r <= UInt16.MaxValue)
return (short)r;

Expand All @@ -2272,7 +2272,7 @@ public static ushort ToUInt16(String value, int fromBase)
return 0;
}

int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
if (r < UInt16.MinValue || r > UInt16.MaxValue)
ThrowUInt16OverflowException();
return (ushort)r;
Expand All @@ -2289,7 +2289,7 @@ public static int ToInt32(String value, int fromBase)
throw new ArgumentException(SR.Arg_InvalidBase);
}
return value != null ?
ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) :
ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight) :
0;
}

Expand All @@ -2305,7 +2305,7 @@ public static uint ToUInt32(String value, int fromBase)
throw new ArgumentException(SR.Arg_InvalidBase);
}
return value != null ?
(uint)ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
(uint)ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
0;
}

Expand All @@ -2320,7 +2320,7 @@ public static long ToInt64(String value, int fromBase)
throw new ArgumentException(SR.Arg_InvalidBase);
}
return value != null ?
ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) :
ParseNumbers.StringToLong(value.AsSpan(), fromBase, ParseNumbers.IsTight) :
0;
}

Expand All @@ -2336,7 +2336,7 @@ public static ulong ToUInt64(String value, int fromBase)
throw new ArgumentException(SR.Arg_InvalidBase);
}
return value != null ?
(ulong)ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
(ulong)ParseNumbers.StringToLong(value.AsSpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) :
0;
}

Expand Down Expand Up @@ -2653,7 +2653,7 @@ public static bool TryFromBase64String(string s, Span<byte> bytes, out int bytes
throw new ArgumentNullException(nameof(s));
}

return TryFromBase64Chars(s.AsReadOnlySpan(), bytes, out bytesWritten);
return TryFromBase64Chars(s.AsSpan(), bytes, out bytesWritten);
}

public static unsafe bool TryFromBase64Chars(ReadOnlySpan<char> chars, Span<byte> bytes, out int bytesWritten)
Expand Down
16 changes: 8 additions & 8 deletions src/mscorlib/shared/System/Globalization/CompareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public virtual int Compare(string string1, string string2, CompareOptions option
return String.CompareOrdinal(string1, string2);
}

return CompareString(string1.AsReadOnlySpan(), string2.AsReadOnlySpan(), options);
return CompareString(string1.AsSpan(), string2.AsSpan(), options);
}

// TODO https://github.com/dotnet/coreclr/issues/13827:
Expand All @@ -354,7 +354,7 @@ internal int Compare(ReadOnlySpan<char> string1, string string2, CompareOptions
{
if (options == CompareOptions.OrdinalIgnoreCase)
{
return CompareOrdinalIgnoreCase(string1, string2.AsReadOnlySpan());
return CompareOrdinalIgnoreCase(string1, string2.AsSpan());
}

// Verify the options before we do any real comparison.
Expand All @@ -365,7 +365,7 @@ internal int Compare(ReadOnlySpan<char> string1, string string2, CompareOptions
throw new ArgumentException(SR.Argument_CompareOptionOrdinal, nameof(options));
}

return string.CompareOrdinal(string1, string2.AsReadOnlySpan());
return string.CompareOrdinal(string1, string2.AsSpan());
}

if ((options & ValidCompareMaskOffFlags) != 0)
Expand All @@ -382,8 +382,8 @@ internal int Compare(ReadOnlySpan<char> string1, string string2, CompareOptions
if (_invariantMode)
{
return (options & CompareOptions.IgnoreCase) != 0 ?
CompareOrdinalIgnoreCase(string1, string2.AsReadOnlySpan()) :
string.CompareOrdinal(string1, string2.AsReadOnlySpan());
CompareOrdinalIgnoreCase(string1, string2.AsSpan()) :
string.CompareOrdinal(string1, string2.AsSpan());
}

return CompareString(string1, string2, options);
Expand Down Expand Up @@ -526,8 +526,8 @@ public virtual int Compare(string string1, int offset1, int length1, string stri
}

return CompareString(
string1.AsReadOnlySpan().Slice(offset1, length1),
string2.AsReadOnlySpan().Slice(offset2, length2),
string1.AsSpan().Slice(offset1, length1),
string2.AsSpan().Slice(offset2, length2),
options);
}

Expand All @@ -551,7 +551,7 @@ internal static int CompareOrdinalIgnoreCase(string strA, int indexA, int length
{
Debug.Assert(indexA + lengthA <= strA.Length);
Debug.Assert(indexB + lengthB <= strB.Length);
return CompareOrdinalIgnoreCase(strA.AsReadOnlySpan().Slice(indexA, lengthA), strB.AsReadOnlySpan().Slice(indexB, lengthB));
return CompareOrdinalIgnoreCase(strA.AsSpan().Slice(indexA, lengthA), strB.AsSpan().Slice(indexB, lengthB));
}

internal static unsafe int CompareOrdinalIgnoreCase(ReadOnlySpan<char> strA, ReadOnlySpan<char> strB)
Expand Down
4 changes: 2 additions & 2 deletions src/mscorlib/shared/System/Globalization/DateTimeParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5045,7 +5045,7 @@ internal bool MatchSpecifiedWords(String target, bool checkWordBoundary, ref int
{
return false;
}
if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsReadOnlySpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0)
if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsSpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0)
{
return false;
}
Expand All @@ -5071,7 +5071,7 @@ internal bool MatchSpecifiedWords(String target, bool checkWordBoundary, ref int
{
return false;
}
if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsReadOnlySpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0)
if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsSpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static int GetAdvanceHijriDate()
{
try
{
int advance = Int32.Parse(str.AsReadOnlySpan().Slice(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture);
int advance = Int32.Parse(str.AsSpan().Slice(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture);
if ((advance >= MinAdvancedHijri) && (advance <= MaxAdvancedHijri))
{
hijriAdvance = advance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static EraInfo GetEraFromValue(String value, String data)
int month;
int day;

ReadOnlySpan<char> valueSpan = value.AsReadOnlySpan();
ReadOnlySpan<char> valueSpan = value.AsSpan();
if (!Int32.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) ||
!Int32.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) ||
!Int32.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day))
Expand Down
4 changes: 2 additions & 2 deletions src/mscorlib/shared/System/IO/Path.Unix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static bool IsPathRooted(string path)
if (path == null)
return false;

return IsPathRooted(path.AsReadOnlySpan());
return IsPathRooted(path.AsSpan());
}

public static bool IsPathRooted(ReadOnlySpan<char> path)
Expand All @@ -128,7 +128,7 @@ public static string GetPathRoot(string path)

public static ReadOnlySpan<char> GetPathRoot(ReadOnlySpan<char> path)
{
return PathInternal.IsEffectivelyEmpty(path) && IsPathRooted(path) ? PathInternal.DirectorySeparatorCharAsString.AsReadOnlySpan() : ReadOnlySpan<char>.Empty;
return PathInternal.IsEffectivelyEmpty(path) && IsPathRooted(path) ? PathInternal.DirectorySeparatorCharAsString.AsSpan() : ReadOnlySpan<char>.Empty;
}

/// <summary>Gets whether the system is case-sensitive.</summary>
Expand Down
10 changes: 5 additions & 5 deletions src/mscorlib/shared/System/IO/Path.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ public static string GetFullPath(string path, string basePath)
// Path is current drive rooted i.e. starts with \:
// "\Foo" and "C:\Bar" => "C:\Foo"
// "\Foo" and "\\?\C:\Bar" => "\\?\C:\Foo"
combinedPath = CombineNoChecks(GetPathRoot(basePath), path.AsReadOnlySpan().Slice(1));
combinedPath = CombineNoChecks(GetPathRoot(basePath), path.AsSpan().Slice(1));
}
else if (length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar)
{
// Drive relative paths
Debug.Assert(length == 2 || !PathInternal.IsDirectorySeparator(path[2]));

if (StringSpanHelpers.Equals(GetVolumeName(path.AsReadOnlySpan()), GetVolumeName(basePath.AsReadOnlySpan())))
if (StringSpanHelpers.Equals(GetVolumeName(path.AsSpan()), GetVolumeName(basePath.AsSpan())))
{
// Matching root
// "C:Foo" and "C:\Bar" => "C:\Bar\Foo"
// "C:Foo" and "\\?\C:\Bar" => "\\?\C:\Bar\Foo"
combinedPath = CombineNoChecks(basePath, path.AsReadOnlySpan().Slice(2));
combinedPath = CombineNoChecks(basePath, path.AsSpan().Slice(2));
}
else
{
Expand Down Expand Up @@ -144,7 +144,7 @@ public static string GetTempFileName()
// if it starts with a backslash ("\") or a valid drive letter and a colon (":").
public static bool IsPathRooted(string path)
{
return path != null && IsPathRooted(path.AsReadOnlySpan());
return path != null && IsPathRooted(path.AsSpan());
}

public static bool IsPathRooted(ReadOnlySpan<char> path)
Expand All @@ -168,7 +168,7 @@ public static string GetPathRoot(string path)
if (PathInternal.IsEffectivelyEmpty(path))
return null;

ReadOnlySpan<char> result = GetPathRoot(path.AsReadOnlySpan());
ReadOnlySpan<char> result = GetPathRoot(path.AsSpan());
if (path.Length == result.Length)
return PathInternal.NormalizeDirectorySeparators(path);

Expand Down
22 changes: 11 additions & 11 deletions src/mscorlib/shared/System/IO/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static string GetExtension(string path)
if (path == null)
return null;

return new string(GetExtension(path.AsReadOnlySpan()));
return new string(GetExtension(path.AsSpan()));
}

/// <summary>
Expand Down Expand Up @@ -169,7 +169,7 @@ public static string GetFileName(string path)
if (path == null)
return null;

ReadOnlySpan<char> result = GetFileName(path.AsReadOnlySpan());
ReadOnlySpan<char> result = GetFileName(path.AsSpan());
if (path.Length == result.Length)
return path;

Expand Down Expand Up @@ -200,7 +200,7 @@ public static string GetFileNameWithoutExtension(string path)
if (path == null)
return null;

ReadOnlySpan<char> result = GetFileNameWithoutExtension(path.AsReadOnlySpan());
ReadOnlySpan<char> result = GetFileNameWithoutExtension(path.AsSpan());
if (path.Length == result.Length)
return path;

Expand Down Expand Up @@ -254,7 +254,7 @@ public static bool IsPathFullyQualified(string path)
if (path == null)
throw new ArgumentNullException(nameof(path));

return IsPathFullyQualified(path.AsReadOnlySpan());
return IsPathFullyQualified(path.AsSpan());
}

public static bool IsPathFullyQualified(ReadOnlySpan<char> path)
Expand All @@ -271,7 +271,7 @@ public static bool HasExtension(string path)
{
if (path != null)
{
return HasExtension(path.AsReadOnlySpan());
return HasExtension(path.AsSpan());
}
return false;
}
Expand Down Expand Up @@ -411,7 +411,7 @@ private static string CombineNoChecks(string first, string second)
if (string.IsNullOrEmpty(second))
return first;

if (IsPathRooted(second.AsReadOnlySpan()))
if (IsPathRooted(second.AsSpan()))
return second;

return CombineNoChecksInternal(first, second);
Expand Down Expand Up @@ -443,9 +443,9 @@ private static string CombineNoChecks(string first, string second, string third)
if (string.IsNullOrEmpty(third))
return CombineNoChecks(first, second);

if (IsPathRooted(third.AsReadOnlySpan()))
if (IsPathRooted(third.AsSpan()))
return third;
if (IsPathRooted(second.AsReadOnlySpan()))
if (IsPathRooted(second.AsSpan()))
return CombineNoChecks(second, third);

return CombineNoChecksInternal(first, second, third);
Expand Down Expand Up @@ -483,11 +483,11 @@ private static string CombineNoChecks(string first, string second, string third,
if (string.IsNullOrEmpty(fourth))
return CombineNoChecks(first, second, third);

if (IsPathRooted(fourth.AsReadOnlySpan()))
if (IsPathRooted(fourth.AsSpan()))
return fourth;
if (IsPathRooted(third.AsReadOnlySpan()))
if (IsPathRooted(third.AsSpan()))
return CombineNoChecks(third, fourth);
if (IsPathRooted(second.AsReadOnlySpan()))
if (IsPathRooted(second.AsSpan()))
return CombineNoChecks(second, third, fourth);

return CombineNoChecksInternal(first, second, third, fourth);
Expand Down
4 changes: 2 additions & 2 deletions src/mscorlib/shared/System/IO/StreamWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public override void Write(string value)
{
if (value != null)
{
WriteCore(value.AsReadOnlySpan(), _autoFlush);
WriteCore(value.AsSpan(), _autoFlush);
}
}

Expand All @@ -445,7 +445,7 @@ public override void WriteLine(string value)
CheckAsyncTaskInProgress();
if (value != null)
{
WriteCore(value.AsReadOnlySpan(), autoFlush: false);
WriteCore(value.AsSpan(), autoFlush: false);
}
WriteCore(new ReadOnlySpan<char>(CoreNewLine), autoFlush: true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/shared/System/Number.Formatting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ private static bool TryCopyTo(string source, Span<char> destination, out int cha
{
Debug.Assert(source != null);

if (source.AsReadOnlySpan().TryCopyTo(destination))
if (source.AsSpan().TryCopyTo(destination))
{
charsWritten = source.Length;
return true;
Expand Down
Loading

0 comments on commit 22f1bc0

Please sign in to comment.