Remove selfCopyBytes in favor of copyBytes

This commit is contained in:
Kenny Daniel 2025-03-10 20:56:00 -07:00
parent 2cd582ea5a
commit a9467f6c3d
No known key found for this signature in database
GPG Key ID: 90AB653A8CAD7E45

@ -22,21 +22,6 @@ function copyBytes(fromArray, fromPos, toArray, toPos, length) {
}
}
/**
* Copy bytes within an array
*
* @param {Uint8Array} array source and destination array
* @param {number} pos source position
* @param {number} offset offset back from current position to read
* @param {number} length number of bytes to copy
* @returns {void}
*/
function selfCopyBytes(array, pos, offset, length) {
for (let i = 0; i < length; i++) {
array[pos + i] = array[pos - offset + i]
}
}
/**
* Decompress snappy data.
* Accepts an output buffer to avoid allocating a new buffer for each call.
@ -135,7 +120,7 @@ export function snappyUncompress(input, output) {
if (offset > outPos) {
throw new Error('cannot copy from before start of buffer')
}
selfCopyBytes(output, outPos, offset, len)
copyBytes(output, outPos - offset, output, outPos, len)
outPos += len
}
}