diff --git a/src/Nethermind/Nethermind.Core/Extensions/Bytes.cs b/src/Nethermind/Nethermind.Core/Extensions/Bytes.cs index cdbdd104a4a..3e1f5460b85 100644 --- a/src/Nethermind/Nethermind.Core/Extensions/Bytes.cs +++ b/src/Nethermind/Nethermind.Core/Extensions/Bytes.cs @@ -145,20 +145,12 @@ public static bool GetBit(this byte b, int bitNumber) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void SetBit(this ref byte b, int bitNumber) { - byte mask = (byte)(1 << (7 - bitNumber)); - b = b |= mask; + int mask = (1 << (7 - bitNumber)); + b |= (byte)mask; } public static int GetHighestSetBitIndex(this byte b) - { - if ((b & 128) == 128) return 8; - if ((b & 64) == 64) return 7; - if ((b & 32) == 32) return 6; - if ((b & 16) == 16) return 5; - if ((b & 8) == 8) return 4; - if ((b & 4) == 4) return 3; - return (b & 2) == 2 ? 2 : b; - } + => 32 - BitOperations.LeadingZeroCount((uint)b); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool AreEqual(ReadOnlySpan a1, ReadOnlySpan a2)