mafintosh / tar-stream

tar-stream is a streaming tar parser and generator.
MIT License
400 stars 93 forks source link

Reduce `b4a` usage and prefer the native `Buffer` methods #163

Closed SukkaW closed 6 months ago

SukkaW commented 6 months ago

The PR reduces some b4a usages:

By replacing those b4a usage with Node.js built-in Buffer, the PR improves performance (as those alias methods would create extra stacks), and makes it easier to transition to the Uint8Array in future PRs.

The unit tests still pass after the changes.

mafintosh commented 6 months ago

The b4a is there to make it run in the browser, overhead is negligible, and prop even optimised out by v8

SukkaW commented 6 months ago

The b4a is there to make it run in the browser, overhead is negligible, and prop even optimised out by v8

@mafintosh Sure, that makes sense.

My original plan was to entirely transition from Buffer to Uint8Array as a preliminary step towards resolving the issue #157. This would begin with unifying Buffer usage followed by subsequent PRs focusing on migrating away from Buffer.

Maybe I should open a PR to migrate to Uint8Array directly, what do you think?