Use alternate any_multiple_needles
detection
#1835
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes tidyverse/dplyr#6835
We can't use the simple
loc < size_needles
check to see if we are in the "extra" match section. When a filter is involved, that isn't enough because we could have filtered out a match that occurred before the extra matches, so the extra match could actually be the first one.However, since we process the
needles
in sequential order (i.e. needles 1 containment group 1, needle 1 containment group 2, needle 2 containment group 1, etc) we can track the previous needles loc inloc_needles_previous
as a more correct way to see if we've already seen 1 match for that particularneedle
.