Skip to content

Commit fad273d

Browse files
committed
Use it in a few places
1 parent 849a107 commit fad273d

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

src/libraries/Common/src/System/Net/CookieComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ internal static bool Equals(Cookie left, Cookie right)
2424

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

3030
return left.Equals(right, StringComparison.OrdinalIgnoreCase);
3131
}

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ private static void BuildCommandLine(ProcessStartInfo startInfo, ref ValueString
674674
// problems (it specifies exactly which part of the string
675675
// is the file to execute).
676676
ReadOnlySpan<char> fileName = startInfo.FileName.AsSpan().Trim();
677-
bool fileNameIsQuoted = fileName.Length > 0 && fileName[0] == '\"' && fileName[fileName.Length - 1] == '\"';
677+
bool fileNameIsQuoted = fileName.StartsWith('"') && fileName.EndsWith('"');
678678
if (!fileNameIsQuoted)
679679
{
680680
commandLine.Append('"');

src/libraries/System.Memory/src/System/Buffers/SequenceReader.Search.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private bool TryReadToSlow(out ReadOnlySequence<T> sequence, T delimiter, T deli
142142
else
143143
{
144144
// No delimiter, need to check the end of the span for odd number of escapes then advance
145-
if (remaining.Length > 0 && remaining[remaining.Length - 1].Equals(delimiterEscape))
145+
if (remaining.EndsWith(delimiterEscape))
146146
{
147147
int escapeCount = 1;
148148
int i = remaining.Length - 2;

src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ internal bool IsFileSystemEntryHidden(ReadOnlySpan<char> path, ReadOnlySpan<char
168168
return HasHiddenFlag;
169169
}
170170

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

173173
// Returns true if the path points to a directory, or if the path is a symbolic link
174174
// that points to a directory

src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static bool IsPathRooted([NotNullWhen(true)] string? path)
137137

138138
public static bool IsPathRooted(ReadOnlySpan<char> path)
139139
{
140-
return path.Length > 0 && path[0] == PathInternal.DirectorySeparatorChar;
140+
return path.StartsWith(PathInternal.DirectorySeparatorChar);
141141
}
142142

143143
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private static bool FilterNameImpl(MemberInfo m, object filterCriteria, StringCo
508508
}
509509

510510
// Check to see if this is a prefix or exact match requirement
511-
if (str.Length > 0 && str[str.Length - 1] == '*')
511+
if (str.EndsWith('*'))
512512
{
513513
str = str.Slice(0, str.Length - 1);
514514
return name.StartsWith(str, comparison);

src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ internal static byte[] LaxDecodeHexString(this string hexString)
8484

8585
ReadOnlySpan<char> s = hexString;
8686

87-
if (s.Length != 0 && s[0] == '\u200E')
87+
if (s.StartsWith('\u200E'))
8888
{
8989
s = s.Slice(1);
9090
}

0 commit comments

Comments
 (0)