Skip to content

Commit

Permalink
revert(Implode): change back optimization inside outputBits()
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 29, 2024
1 parent 6a33740 commit b90c25e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Implode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,17 @@ export class Implode {
const lastBytes = this.outputBuffer.readByte(this.outputBuffer.size() - 1)
this.outputBuffer.setByte(-1, lastBytes | getLowestNBitsOf(bitBuffer << outBits, 8))

this.outBits = getLowestNBitsOf(this.outBits + nBits, 3)
this.outBits = this.outBits + nBits

if (this.outBits > 8) {
this.outBits = getLowestNBitsOf(this.outBits, 3)
bitBuffer = bitBuffer >> (8 - outBits)
this.outputBuffer.appendByte(getLowestNBitsOf(bitBuffer, 8))
} else if (this.outBits === 0) {
this.outputBuffer.appendByte(0)
} else {
this.outBits = getLowestNBitsOf(this.outBits, 3)
if (this.outBits === 0) {
this.outputBuffer.appendByte(0)
}
}
}
}

0 comments on commit b90c25e

Please sign in to comment.