-
Notifications
You must be signed in to change notification settings - Fork 283
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
Use different search algorithm in Strings::contains_any
#1255
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
src/vcpkg/base/strings.cpp
Outdated
for (const auto& subject : to_find) | ||
{ | ||
auto found = | ||
std::search(source.begin(), source.end(), boyer_moore_horspool_searcher(subject.begin(), subject.end())); |
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.
Creating the searcher should be hoist out of the loop
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.
Nevermind I'm an idiot.
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.
Although I do think this should be hoist to just after
auto files = fs.get_regular_files_recursive(dir, IgnoreErrors{});
in postbuildlint.cpp
.
My concern is that contains_any
looks like it's doing contains
, not boyer_moore things, and I could easily see that being used in places boyer_moore would be inappropriate.
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.
I either think contains_any
should be renamed to indicate that it only makes sense for long haystacks now, and/or it should be given a View<boyer_moore_horspool_searcher>
instead of the raw text.
Thanks! |
I now get 467 warnings of the form
|
Honestly, I don't know what the best solution is. I could check for the feature test macro but then we don't get informed when we can remove this workaround. |
This should have the effect of disabling this on macOS which hopefully fixes the Python2 hang. Related: microsoft#1255
This should have the effect of disabling this on macOS which hopefully fixes the Python2 hang. Related: #1255
Using
std::boyer_moore_horspool_searcher
results in approx. 3x speedup ofStrings::contains_any()
which is used bycontains_any_ignoring_c_comments()
during post build lint.Note that this search algorithm is only useful when dealing with long strings: cppreference