Simplify ReadBitsIntBe as in kaitai-io/kaitai_struct_java_runtime@e1a30e4
This commit is contained in:
parent
37d3c319d9
commit
2b39ce9bc8
|
@ -307,11 +307,9 @@ namespace Kaitai
|
|||
|
||||
// raw mask with required number of 1s, starting from lowest bit
|
||||
ulong mask = GetMaskOnes(n);
|
||||
// shift mask to align with highest bits available in "bits"
|
||||
// shift "bits" to align the highest bits with the mask & derive reading result
|
||||
int shiftBits = BitsLeft - n;
|
||||
mask = mask << shiftBits;
|
||||
// derive reading result
|
||||
ulong res = (Bits & mask) >> shiftBits;
|
||||
ulong res = (Bits >> shiftBits) & mask;
|
||||
// clear top bits that we've just read => AND with 1s
|
||||
BitsLeft -= n;
|
||||
mask = GetMaskOnes(BitsLeft);
|
||||
|
|
Loading…
Reference in New Issue