Skip to content

Commit 256ea09

Browse files
committed
slightly faster
1 parent 174a54b commit 256ea09

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

FTMS.NET/Utils/ByteExtensions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public static bool IsBitSet(this ReadOnlySpan<byte> data, int pos)
3131
}
3232

3333
public static bool IsBitSet(this byte b, int pos)
34-
=> pos < 0 || pos > 7 ?
35-
throw new IndexOutOfRangeException() :
36-
(b & 1 << pos) != 0;
34+
{
35+
if ((uint)pos > 7)
36+
throw new IndexOutOfRangeException();
37+
38+
return ((b >> pos) & 1) != 0;
39+
}
3740
}

0 commit comments

Comments
 (0)