-
Notifications
You must be signed in to change notification settings - Fork 69
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
indexOf that conforms to nodejs 10 tests #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about you add a fast-path for indexOf sequences that sre 1 byte only?
LGTM on this, the optimization can come on a follow-up PR.
This is a JS implementation of indexOf for searching for BufferLists, Buffers, strings and numbers inside a BufferList. It passes the node 10 buffer indexof test suite and works on node 4+. There are quite of a few performance improvements possible, single byte search values can use the native Buffer.indexOf command. Multibyte buffer search values could too with some extra work. I don't believe searching for another buffer list can easily be made faster. This takes largely from two places and brings them together - The nodejs buffer index of tests https://github.com/nodejs/node/blob/5d8373a498a50b1387464391402ef22636439303/test/parallel/test-buffer-indexof.js - from @soldair's node-buffer-indexof https://www.npmjs.com/package/buffer-indexof
71fff46
to
0d4d16a
Compare
Removed the extra semicolons. I'll take a wack at the optimizations but I figured the test suite would help make that happen. |
Thee 1 byte search was pretty straightforward, I'm still scratching my head at using a windowing approach for native indexOf for multibyte search. Anyway that's for another PR. if this checks out I'm done here 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a JS implementation of indexOf for searching for BufferLists, Buffers, strings and numbers inside a BufferList. It passes the node 10 buffer indexof test suite and works on node 4+.
There are quite of a few performance improvements possible, single byte search values can use the native Buffer.indexOf command. Multibyte buffer search values could too with some extra work. I don't believe searching for another buffer list can be made much faster.
This takes largely from two places and brings them together
closes #58