Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Text\SpanRuneEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.Debug.cs" Condition="'$(Configuration)' == 'Debug'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilderRuneEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringRuneEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\TranscodingStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\TrimType.cs" />
Expand Down
13 changes: 0 additions & 13 deletions src/libraries/System.Private.CoreLib/src/System/Char.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ public bool Equals(char obj)
return m_value == obj;
}

internal bool Equals(char right, StringComparison comparisonType)
{
switch (comparisonType)
{
case StringComparison.Ordinal:
return Equals(right);
default:
ReadOnlySpan<char> leftCharsSlice = [this];
ReadOnlySpan<char> rightCharsSlice = [right];
return leftCharsSlice.Equals(rightCharsSlice, comparisonType);
}
}

// Compares this object to another object, returning an integer that
// indicates the relationship.
// Returns a value less than zero if this object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,6 @@ public string ToLower(string str)
return ChangeCaseCommon<ToLowerConversion>(str);
}

internal void ToLower(ReadOnlySpan<char> source, Span<char> destination)
{
if (GlobalizationMode.Invariant)
{
InvariantModeCasing.ToLower(source, destination);
return;
}

ChangeCaseCommon<ToLowerConversion>(source, destination);
}

private unsafe char ChangeCase(char c, bool toUpper)
{
Debug.Assert(!GlobalizationMode.Invariant);
Expand Down Expand Up @@ -462,17 +451,6 @@ public string ToUpper(string str)
return ChangeCaseCommon<ToUpperConversion>(str);
}

internal void ToUpper(ReadOnlySpan<char> source, Span<char> destination)
{
if (GlobalizationMode.Invariant)
{
InvariantModeCasing.ToUpper(source, destination);
return;
}

ChangeCaseCommon<ToUpperConversion>(source, destination);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static char ToUpperAsciiInvariant(char c)
{
Expand All @@ -483,50 +461,6 @@ internal static char ToUpperAsciiInvariant(char c)
return c;
}

/// <summary>
/// Converts the specified rune to lowercase.
/// </summary>
/// <param name="value">The rune to convert to lowercase.</param>
/// <returns>The specified rune converted to lowercase.</returns>
public Rune ToLower(Rune value)
{
// Convert rune to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

// Change span to lower and convert to rune
if (valueChars.Length == 2)
{
Span<char> lowerChars = stackalloc char[2];
ToLower(valueChars, lowerChars);
return new Rune(lowerChars[0], lowerChars[1]);
}

char lowerChar = ToLower(valueChars[0]);
return new Rune(lowerChar);
}

/// <summary>
/// Converts the specified rune to uppercase.
/// </summary>
/// <param name="value">The rune to convert to uppercase.</param>
/// <returns>The specified rune converted to uppercase.</returns>
public Rune ToUpper(Rune value)
{
// Convert rune to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

// Change span to upper and convert to rune
if (valueChars.Length == 2)
{
Span<char> upperChars = stackalloc char[2];
ToUpper(valueChars, upperChars);
return new Rune(upperChars[0], upperChars[1]);
}

char upperChar = ToUpper(valueChars[0]);
return new Rune(upperChar);
}

private bool IsAsciiCasingSameAsInvariant
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
81 changes: 0 additions & 81 deletions src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,6 @@ public virtual void Write(char value)
{
}

/// <summary>
/// Writes a rune to the text stream.
/// </summary>
/// <param name="value">The rune to write to the text stream.</param>
public virtual void Write(Rune value)
{
// Convert value to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

// Write span
Write(valueChars[0]);
if (valueChars.Length > 1)
{
Write(valueChars[1]);
}
}

// Writes a character array to the text stream. This default method calls
// Write(char) for each of the characters in the character array.
// If the character array is null, nothing is written.
Expand Down Expand Up @@ -360,26 +343,6 @@ public virtual void WriteLine(char value)
WriteLine();
}

/// <summary>
/// Writes a rune followed by a line terminator to the text stream.
/// </summary>
/// <param name="value">The rune to write to the text stream.</param>
public virtual void WriteLine(Rune value)
{
// Convert value to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

if (valueChars.Length > 1)
{
Write(valueChars[0]);
WriteLine(valueChars[1]);
}
else
{
WriteLine(valueChars[0]);
}
}

// Writes an array of characters followed by a line terminator to the text
// stream.
//
Expand Down Expand Up @@ -579,28 +542,6 @@ public virtual Task WriteAsync(char value) =>
t.Item1.Write(t.Item2);
}, new TupleSlim<TextWriter, char>(this, value), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);

/// <summary>
/// Writes a rune to the text stream asynchronously.
/// </summary>
/// <param name="value">The rune to write to the text stream.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
public virtual Task WriteAsync(Rune value)
{
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

if (valueChars.Length > 1)
{
return Task.Factory.StartNew(static state =>
{
var t = (TupleSlim<TextWriter, char, char>)state!;
t.Item1.Write(t.Item2);
t.Item1.Write(t.Item3);
}, new TupleSlim<TextWriter, char, char>(this, valueChars[0], valueChars[1]), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
}

return WriteAsync(valueChars[0]);
}

public virtual Task WriteAsync(string? value) =>
Task.Factory.StartNew(static state =>
{
Expand Down Expand Up @@ -664,28 +605,6 @@ public virtual Task WriteLineAsync(char value) =>
t.Item1.WriteLine(t.Item2);
}, new TupleSlim<TextWriter, char>(this, value), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);

/// <summary>
/// Writes a rune followed by a line terminator to the text stream asynchronously.
/// </summary>
/// <param name="value">The rune to write to the text stream.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
public virtual Task WriteLineAsync(Rune value)
{
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

if (valueChars.Length > 1)
{
return Task.Factory.StartNew(static state =>
{
var t = (TupleSlim<TextWriter, char, char>)state!;
t.Item1.Write(t.Item2);
t.Item1.WriteLine(t.Item3);
}, new TupleSlim<TextWriter, char, char>(this, valueChars[0], valueChars[1]), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
}

return WriteLineAsync(valueChars[0]);
}

public virtual Task WriteLineAsync(string? value) =>
Task.Factory.StartNew(static state =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Unicode;

namespace System
Expand Down Expand Up @@ -590,44 +589,6 @@ public bool EndsWith(char value)
return ((uint)lastPos < (uint)Length) && this[lastPos] == value;
}

/// <summary>
/// Determines whether the end of this string instance matches the specified character.
/// </summary>
/// <param name="value">The character to compare to the character at the end of this instance.</param>
/// <param name="comparisonType">One of the enumeration values that specifies the rules to use in the comparison.</param>
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
public bool EndsWith(char value, StringComparison comparisonType)
{
// Convert value to span
ReadOnlySpan<char> valueChars = [value];

return this.EndsWith(valueChars, comparisonType);
}

/// <summary>
/// Determines whether the end of this string instance matches the specified rune using an ordinal comparison.
/// </summary>
/// <param name="value">The character to compare to the character at the end of this instance.</param>
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
public bool EndsWith(Rune value)
{
return EndsWith(value, StringComparison.Ordinal);
}

/// <summary>
/// Determines whether the end of this string instance matches the specified rune when compared using the specified comparison option.
/// </summary>
/// <param name="value">The character to compare to the character at the end of this instance.</param>
/// <param name="comparisonType">One of the enumeration values that specifies the rules to use in the comparison.</param>
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
public bool EndsWith(Rune value, StringComparison comparisonType)
{
// Convert value to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

return this.EndsWith(valueChars, comparisonType);
}

// Determines whether two strings match.
public override bool Equals([NotNullWhen(true)] object? obj)
{
Expand Down Expand Up @@ -1201,44 +1162,6 @@ public bool StartsWith(char value)
return Length != 0 && _firstChar == value;
}

/// <summary>
/// Determines whether the beginning of this string instance matches the specified character when compared using the specified comparison option.
/// </summary>
/// <param name="value">The character to compare.</param>
/// <param name="comparisonType">One of the enumeration values that determines how this string and <paramref name="value"/> are compared.</param>
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
public bool StartsWith(char value, StringComparison comparisonType)
{
// Convert value to span
ReadOnlySpan<char> valueChars = [value];

return this.StartsWith(valueChars, comparisonType);
}

/// <summary>
/// Determines whether the beginning of this string instance matches the specified rune using an ordinal comparison.
/// </summary>
/// <param name="value">The rune to compare.</param>
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
public bool StartsWith(Rune value)
{
return StartsWith(value, StringComparison.Ordinal);
}

/// <summary>
/// Determines whether the beginning of this string instance matches the specified rune when compared using the specified comparison option.
/// </summary>
/// <param name="value">The rune to compare.</param>
/// <param name="comparisonType">One of the enumeration values that determines how this string and <paramref name="value"/> are compared.</param>
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
public bool StartsWith(Rune value, StringComparison comparisonType)
{
// Convert value to span
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);

return this.StartsWith(valueChars, comparisonType);
}

internal static void CheckStringComparison(StringComparison comparisonType)
{
// Single comparison to check if comparisonType is within [CurrentCulture .. OrdinalIgnoreCase]
Expand Down
Loading
Loading