Skip to content

Commit 887ccac

Browse files
authored
Use uint.TrailingZeroCount
1 parent 3989e4d commit 887ccac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/libraries/System.Private.CoreLib/src/System/Globalization/Ordinal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ ref Unsafe.Add(ref valueRef, 1), valueTailLength))
462462
// Do a full IgnoreCase equality comparison. SpanHelpers.IndexOf skips comparing the two characters in some cases,
463463
// but we don't actually know that the two characters are equal, since we compared with | 0x20. So we just compare
464464
// the full string always.
465-
nint charPos = (nint)((uint)BitOperations.TrailingZeroCount(mask) / sizeof(ushort));
465+
nint charPos = (nint)(uint.TrailingZeroCount(mask) / sizeof(ushort));
466466
if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length))
467467
{
468468
// Match! Return the index.
@@ -528,7 +528,7 @@ ref Unsafe.Add(ref valueRef, 1), valueTailLength))
528528
// Do a full IgnoreCase equality comparison. SpanHelpers.IndexOf skips comparing the two characters in some cases,
529529
// but we don't actually know that the two characters are equal, since we compared with | 0x20. So we just compare
530530
// the full string always.
531-
nint charPos = (nint)((uint)BitOperations.TrailingZeroCount(mask) / sizeof(ushort));
531+
nint charPos = (nint)(uint.TrailingZeroCount(mask) / sizeof(ushort));
532532
if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length))
533533
{
534534
// Match! Return the index.

src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + 1)),
114114
uint mask = cmpAnd.ExtractMostSignificantBits();
115115
do
116116
{
117-
nint charPos = (nint)((uint)BitOperations.TrailingZeroCount(mask) / sizeof(ushort));
117+
nint charPos = (nint)(uint.TrailingZeroCount(mask) / sizeof(ushort));
118118
if (valueLength == 2 || // we already matched two chars
119119
SequenceEqual(
120120
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)),
@@ -176,7 +176,7 @@ ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2))
176176
uint mask = cmpAnd.ExtractMostSignificantBits();
177177
do
178178
{
179-
nint charPos = (nint)((uint)BitOperations.TrailingZeroCount(mask) / sizeof(ushort));
179+
nint charPos = (nint)(uint.TrailingZeroCount(mask) / sizeof(ushort));
180180
if (valueLength == 2 || // we already matched two chars
181181
SequenceEqual(
182182
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)),

0 commit comments

Comments
 (0)