mirror of
https://github.com/sigmasternchen/axowall
synced 2025-03-15 08:38:55 +00:00
cleanup hasPrefix
This commit is contained in:
parent
187a1a1743
commit
b179c03730
1 changed files with 1 additions and 3 deletions
|
@ -14,10 +14,8 @@ Uint8Array.prototype.hasPrefix = function(prefix: Uint8Array, bits: number): boo
|
|||
for(let i = 0; i < prefix.length && i * 8 < bits; i++) {
|
||||
const bitsForByte = Math.min(8, bits - i * 8);
|
||||
const bitMask = ((1 << bitsForByte) - 1) << (8 - bitsForByte);
|
||||
const currentBits = this[i] & bitMask;
|
||||
const prefixBits = prefix[i] & bitMask;
|
||||
|
||||
if (currentBits != prefixBits) {
|
||||
if ((this[i] & bitMask) != (prefix[i] & bitMask)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue