Skip to content
New issue

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

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

Already on GitHub? # to your account

Add bufrange to support reusing buffers #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martin-knopf
Copy link

@martin-knopf martin-knopf commented Sep 23, 2024

Hi!

I have recently used this library in the context of content-defined chunking, where I read a file into a buffer and calculate hashes of a sliding window. This produces as many hashes as there are bytes in the buffer. To get the next window, I used Buffer.subarray(), but this is pretty slow because it creates a new buffer. So, with this PR, I would like to propose CRC32.bufrange(buffer, start, end, [, seed]), which allows reusing the same buffer.

Unfortunately, I don’t understand your codebase well enough to know where this new function should go. For starters, I have only added it to crc32.js, but I would be happy to complete this PR with your help.

Best, Martin

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant