You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rust-globset/0001-deps-update-to-aho-cor...

116 lines
3.7 KiB

From cd9815cb376e4679af93a90a964cdb78173318da Mon Sep 17 00:00:00 2001
From: Andrew Gallant <jamslam@gmail.com>
Date: Wed, 3 Apr 2019 13:51:26 -0400
Subject: [PATCH] deps: update to aho-corasick 0.7
We do the simplest possible change to migrate to the new version.
Fixes #1228
---
globset/src/lib.rs | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/globset/src/lib.rs b/globset/src/lib.rs
index 7196b8f265fb..a558e15b1c00 100644
--- a/globset/src/lib.rs
+++ b/globset/src/lib.rs
@@ -119,7 +119,7 @@ use std::hash;
use std::path::Path;
use std::str;
-use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton};
+use aho_corasick::AhoCorasick;
use regex::bytes::{Regex, RegexBuilder, RegexSet};
use pathutil::{
@@ -648,7 +648,7 @@ impl ExtensionStrategy {
#[derive(Clone, Debug)]
struct PrefixStrategy {
- matcher: FullAcAutomaton<Vec<u8>>,
+ matcher: AhoCorasick,
map: Vec<usize>,
longest: usize,
}
@@ -656,8 +656,8 @@ struct PrefixStrategy {
impl PrefixStrategy {
fn is_match(&self, candidate: &Candidate) -> bool {
let path = candidate.path_prefix(self.longest);
- for m in self.matcher.find_overlapping(path) {
- if m.start == 0 {
+ for m in self.matcher.find_overlapping_iter(path) {
+ if m.start() == 0 {
return true;
}
}
@@ -666,9 +666,9 @@ impl PrefixStrategy {
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) {
let path = candidate.path_prefix(self.longest);
- for m in self.matcher.find_overlapping(path) {
- if m.start == 0 {
- matches.push(self.map[m.pati]);
+ for m in self.matcher.find_overlapping_iter(path) {
+ if m.start() == 0 {
+ matches.push(self.map[m.pattern()]);
}
}
}
@@ -676,7 +676,7 @@ impl PrefixStrategy {
#[derive(Clone, Debug)]
struct SuffixStrategy {
- matcher: FullAcAutomaton<Vec<u8>>,
+ matcher: AhoCorasick,
map: Vec<usize>,
longest: usize,
}
@@ -684,8 +684,8 @@ struct SuffixStrategy {
impl SuffixStrategy {
fn is_match(&self, candidate: &Candidate) -> bool {
let path = candidate.path_suffix(self.longest);
- for m in self.matcher.find_overlapping(path) {
- if m.end == path.len() {
+ for m in self.matcher.find_overlapping_iter(path) {
+ if m.end() == path.len() {
return true;
}
}
@@ -694,9 +694,9 @@ impl SuffixStrategy {
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) {
let path = candidate.path_suffix(self.longest);
- for m in self.matcher.find_overlapping(path) {
- if m.end == path.len() {
- matches.push(self.map[m.pati]);
+ for m in self.matcher.find_overlapping_iter(path) {
+ if m.end() == path.len() {
+ matches.push(self.map[m.pattern()]);
}
}
}
@@ -781,18 +781,16 @@ impl MultiStrategyBuilder {
}
fn prefix(self) -> PrefixStrategy {
- let it = self.literals.into_iter().map(|s| s.into_bytes());
PrefixStrategy {
- matcher: AcAutomaton::new(it).into_full(),
+ matcher: AhoCorasick::new_auto_configured(&self.literals),
map: self.map,
longest: self.longest,
}
}
fn suffix(self) -> SuffixStrategy {
- let it = self.literals.into_iter().map(|s| s.into_bytes());
SuffixStrategy {
- matcher: AcAutomaton::new(it).into_full(),
+ matcher: AhoCorasick::new_auto_configured(&self.literals),
map: self.map,
longest: self.longest,
}
--
2.20.1