Skip to content

Commit

Permalink
Use it in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Jun 14, 2024
1 parent 23088f5 commit d888248
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/libraries/Common/src/System/Net/CookieComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ internal static bool Equals(Cookie left, Cookie right)

internal static bool EqualDomains(ReadOnlySpan<char> left, ReadOnlySpan<char> right)
{
if (left.Length != 0 && left[0] == '.') left = left.Slice(1);
if (right.Length != 0 && right[0] == '.') right = right.Slice(1);
if (left.StartsWith('.')) left = left.Slice(1);
if (right.StartsWith('.')) right = right.Slice(1);

return left.Equals(right, StringComparison.OrdinalIgnoreCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ private static void BuildCommandLine(ProcessStartInfo startInfo, ref ValueString
// problems (it specifies exactly which part of the string
// is the file to execute).
ReadOnlySpan<char> fileName = startInfo.FileName.AsSpan().Trim();
bool fileNameIsQuoted = fileName.Length > 0 && fileName[0] == '\"' && fileName[fileName.Length - 1] == '\"';
bool fileNameIsQuoted = fileName.StartsWith('"') && fileName.EndsWith('"');
if (!fileNameIsQuoted)
{
commandLine.Append('"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private bool TryReadToSlow(out ReadOnlySequence<T> sequence, T delimiter, T deli
else
{
// No delimiter, need to check the end of the span for odd number of escapes then advance
if (remaining.Length > 0 && remaining[remaining.Length - 1].Equals(delimiterEscape))
if (remaining.EndsWith(delimiterEscape))
{
int escapeCount = 1;
int i = remaining.Length - 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ internal bool IsFileSystemEntryHidden(ReadOnlySpan<char> path, ReadOnlySpan<char
return HasHiddenFlag;
}

internal static bool IsNameHidden(ReadOnlySpan<char> fileName) => fileName.Length > 0 && fileName[0] == '.';
internal static bool IsNameHidden(ReadOnlySpan<char> fileName) => fileName.StartsWith('.');

// Returns true if the path points to a directory, or if the path is a symbolic link
// that points to a directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static bool IsPathRooted([NotNullWhen(true)] string? path)

public static bool IsPathRooted(ReadOnlySpan<char> path)
{
return path.Length > 0 && path[0] == PathInternal.DirectorySeparatorChar;
return path.StartsWith(PathInternal.DirectorySeparatorChar);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private static bool FilterNameImpl(MemberInfo m, object filterCriteria, StringCo
}

// Check to see if this is a prefix or exact match requirement
if (str.Length > 0 && str[str.Length - 1] == '*')
if (str.EndsWith('*'))
{
str = str.Slice(0, str.Length - 1);
return name.StartsWith(str, comparison);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal static byte[] LaxDecodeHexString(this string hexString)

ReadOnlySpan<char> s = hexString;

if (s.Length != 0 && s[0] == '\u200E')
if (s.StartsWith('\u200E'))
{
s = s.Slice(1);
}
Expand Down

0 comments on commit d888248

Please sign in to comment.