File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace FTMS . NET . Utils ;
22
3- public static class ByteExtensions
3+ internal static class ByteExtensions
44{
55 public static bool IsBitSet ( this byte [ ] data , int pos )
66 {
7+ if ( pos < 0 )
8+ throw new IndexOutOfRangeException ( ) ;
9+
710 int byteIndex = pos / 7 ;
811 int bitIndex = pos % 7 ;
912
1013 if ( byteIndex >= data . Length )
11- return false ;
14+ throw new IndexOutOfRangeException ( ) ;
1215
1316 return data [ byteIndex ] . IsBitSet ( bitIndex ) ;
1417 }
1518
1619 public static bool IsBitSet ( this ReadOnlySpan < byte > data , int pos )
1720 {
21+ if ( pos < 0 )
22+ throw new IndexOutOfRangeException ( ) ;
23+
1824 int byteIndex = pos / 7 ;
1925 int bitIndex = pos % 7 ;
2026
2127 if ( byteIndex >= data . Length )
22- return false ;
28+ throw new IndexOutOfRangeException ( ) ;
2329
2430 return data [ byteIndex ] . IsBitSet ( bitIndex ) ;
2531 }
2632
2733 public static bool IsBitSet ( this byte b , int pos )
28- => ( b & 1 << pos ) != 0 ;
34+ => pos < 0 || pos > 7 ?
35+ throw new IndexOutOfRangeException ( ) :
36+ ( b & 1 << pos ) != 0 ;
2937}
You can’t perform that action at this time.
0 commit comments