Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

trevnorris
Copy link
Contributor

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

Improve the performance of IndexOf() for Buffer#indexOf() searches.
@trevnorris
Copy link
Contributor Author

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,
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Fishrock123
Copy link
Contributor

@trevnorris can we close this and re-open a new one when you come up with a good way of doing it?

@trevnorris
Copy link
Contributor Author

@Fishrock123 Sure.

@trevnorris trevnorris closed this Mar 12, 2015
@trevnorris trevnorris deleted the supa-fast-indexof branch March 28, 2016 22:19
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.

4 participants