-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
buffer: make indexOf faster #1059
Conversation
Improve the performance of IndexOf() for Buffer#indexOf() searches.
36cea64
to
e3cdaab
Compare
okay. so it seems that V8's string match is still crazy faster than this. still have a ways to go. |
do { | ||
ptr = memchr(inc, *needle, h_length - static_cast<int32_t>(inc - haystack)); | ||
if (ptr != nullptr) { | ||
const void* ptr2 = memmem(inc, |
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.
Is it available on windows?
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.
Guess it isn't: https://msdn.microsoft.com/en-us/library/aa246468(v=vs.60).aspx
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.
suck, seriously? alright, back to the drawing board.
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.
Maybe just pick a "good" algorithm from here to use on Windows (or everywhere for consistency?). Start with Turbo Boyer-Moore or Boyer-Moore-Horspool perhaps?
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.
@mscdex TBH this implementation was thrown together in 10 mins, and is by no means a good implementation. i'll take the time to read up more on proper Boyer-Moore implementations. Thanks for the links.
@trevnorris can we close this and re-open a new one when you come up with a good way of doing it? |
@Fishrock123 Sure. |
Improve the performance of IndexOf() for Buffer#indexOf() searches.
NOTE: This is very ugly right now, but sooo much faster. Looking for feedback at the moment.
R=@bnoordhuis