src: replace naive search in Buffer::IndexOf
authorKarl Skomski <karl@skomski.com>
Thu, 3 Sep 2015 08:10:30 +0000 (10:10 +0200)
committerJames M Snell <jasnell@gmail.com>
Thu, 8 Oct 2015 04:21:40 +0000 (21:21 -0700)
commitd99336a39125e413ddfa292cd402070e6fc74660
tree2ec2e673de92c3857b6a09378b62b6e4eed6226e
parent3eaa593a320d62a18324f9e9ac36b1fd56042d0d
src: replace naive search in Buffer::IndexOf

Adds the string search implementation from v8
which uses naive search if pattern length < 8
or to a specific badness then uses Boyer-Moore-Horspool

Added benchmark shows the expected improvements
Added option to use ucs2 encoding with Buffer::IndexOf

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2539
benchmark/buffers/buffer-indexof.js [new file with mode: 0644]
benchmark/fixtures/alice.html [new file with mode: 0644]
lib/buffer.js
node.gyp
src/node_buffer.cc
src/string_search.cc [new file with mode: 0644]
src/string_search.h [new file with mode: 0644]
test/parallel/test-buffer-indexof.js