Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Buffer usage optional again #232

Merged
merged 2 commits into from
Aug 18, 2019

Conversation

jacor84
Copy link
Contributor

@jacor84 jacor84 commented Aug 3, 2019

Related to #227 and a comment about browser usage.

This PR makes usage of Buffer optional. If input type is Buffer, zip header searching is conducted with much faster Buffer.indexOf, otherwise single-byte Uint8Array.indexOf is used, which results in many false positives that must be discarded. Thus using Buffer type as input is still the best option in terms of speed and memory usage.

Tested on the same 169MB .zip file as before, resulting in 49ms with Buffer and 465ms without Buffer.

@jacor84
Copy link
Contributor Author

jacor84 commented Aug 8, 2019

@sindresorhus What do you think about it?

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@sindresorhus sindresorhus merged commit dc611b4 into sindresorhus:master Aug 18, 2019
@jacor84 jacor84 deleted the optional-buffer branch August 18, 2019 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants