Skip to content

Conversation

@gurgunday
Copy link
Member

@gurgunday gurgunday commented Nov 28, 2024

lookbehind size doesn't need to be the same size as the needle, the last index is never used

Here's why: if it reaches the needle size with an incoming buffer, we immediately check and empty it anyway, we never store data that has enough length to be compared to the needle, it always has to be at max 1 less, otherwise the check would happen -- it's one of the guarantees of the algorithm

The test changes break nothing, we just had to change lookbehind length in expected checks

@gurgunday
Copy link
Member Author

gurgunday commented Nov 28, 2024

Bench (node 22):

master:

gurgunday@DELL-G15:~/work/OSS/busboy/benchmarks$ npm run benchmark-fastify

> busboy-benchmarks@1.0.0 benchmark-fastify
> node busboy/executioner.js -c 1

Mean time for fastify-busboy is 177610.58582281295 nanoseconds
all done

pr:

gurgunday@DELL-G15:~/work/OSS/busboy/benchmarks$ npm run benchmark-fastify

> busboy-benchmarks@1.0.0 benchmark-fastify
> node busboy/executioner.js -c 1

Mean time for fastify-busboy is 174747.183856004 nanoseconds
all done

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

@gurgunday gurgunday merged commit eece7f3 into master Dec 2, 2024
13 checks passed
@gurgunday gurgunday deleted the lb branch December 2, 2024 20:34
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.

3 participants