mirror of
https://gitee.com/openharmony/third_party_rust_aho-corasick
synced 2024-11-23 07:20:26 +00:00
edition: run 'cargo fix --edition --all'
This commit is contained in:
parent
3852632f10
commit
45a4ee770e
10
Cargo.toml
10
Cargo.toml
@ -13,16 +13,10 @@ autotests = false
|
||||
exclude = [
|
||||
"/aho-corasick-debug", "/ci/*", "/.travis.yml", "/appveyor.yml",
|
||||
]
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = ["bench"]
|
||||
# We'd ideally not do this, but since the debug tool uses Rust 2018, older
|
||||
# versions of Rust (such as 1.28) fail to parse the manifest because it treats
|
||||
# `edition = "2018"` as an unstable feature.
|
||||
#
|
||||
# When we move our MSRV to Rust 2018, then we should be able to add this back
|
||||
# to the workspace.
|
||||
exclude = ["aho-corasick-debug"]
|
||||
members = ["aho-corasick-debug", "bench"]
|
||||
|
||||
[lib]
|
||||
name = "aho_corasick"
|
||||
|
@ -7,6 +7,7 @@ description = "Criterion benchmark suite for aho-corasick."
|
||||
homepage = "https://github.com/BurntSushi/aho-corasick"
|
||||
repository = "https://github.com/BurntSushi/aho-corasick"
|
||||
license = "Unlicense OR MIT"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
@ -1,8 +1,8 @@
|
||||
use aho_corasick::{AhoCorasick, AhoCorasickBuilder};
|
||||
use criterion::{black_box, Criterion};
|
||||
|
||||
use input::{words_15000, words_5000};
|
||||
use {define, define_long};
|
||||
use crate::input::{words_15000, words_5000};
|
||||
use crate::{define, define_long};
|
||||
|
||||
/// Benchmarks that measure the performance of constructing an Aho-Corasick
|
||||
/// automaton.
|
||||
|
@ -1,7 +1,7 @@
|
||||
use criterion::Criterion;
|
||||
|
||||
use input::*;
|
||||
use {define_aho_corasick, define_aho_corasick_dfa};
|
||||
use crate::input::*;
|
||||
use crate::{define_aho_corasick, define_aho_corasick_dfa};
|
||||
|
||||
/// These benchmarks test various words on random text.
|
||||
pub fn all(c: &mut Criterion) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use criterion::Criterion;
|
||||
|
||||
use define_aho_corasick;
|
||||
use crate::define_aho_corasick;
|
||||
|
||||
/// These benchmarks test various workloads on a corpus that corresponds to the
|
||||
/// repetition of a single byte. For the most part, we compare the impact of
|
||||
|
@ -1,7 +1,7 @@
|
||||
use criterion::Criterion;
|
||||
|
||||
use define_aho_corasick;
|
||||
use input::*;
|
||||
use crate::define_aho_corasick;
|
||||
use crate::input::*;
|
||||
|
||||
/// These benchmarks test various words on natural language text.
|
||||
///
|
||||
|
@ -1,14 +1,14 @@
|
||||
use std::io;
|
||||
|
||||
use automaton::Automaton;
|
||||
use buffer::Buffer;
|
||||
use dfa::{self, DFA};
|
||||
use error::Result;
|
||||
use nfa::{self, NFA};
|
||||
use packed;
|
||||
use prefilter::{Prefilter, PrefilterState};
|
||||
use state_id::StateID;
|
||||
use Match;
|
||||
use crate::automaton::Automaton;
|
||||
use crate::buffer::Buffer;
|
||||
use crate::dfa::{self, DFA};
|
||||
use crate::error::Result;
|
||||
use crate::nfa::{self, NFA};
|
||||
use crate::packed;
|
||||
use crate::prefilter::{Prefilter, PrefilterState};
|
||||
use crate::state_id::StateID;
|
||||
use crate::Match;
|
||||
|
||||
/// An automaton for searching multiple strings in linear time.
|
||||
///
|
||||
|
@ -1,7 +1,7 @@
|
||||
use ahocorasick::MatchKind;
|
||||
use prefilter::{self, Candidate, Prefilter, PrefilterState};
|
||||
use state_id::{dead_id, fail_id, StateID};
|
||||
use Match;
|
||||
use crate::ahocorasick::MatchKind;
|
||||
use crate::prefilter::{self, Candidate, Prefilter, PrefilterState};
|
||||
use crate::state_id::{dead_id, fail_id, StateID};
|
||||
use crate::Match;
|
||||
|
||||
// NOTE: This trait essentially started as a copy of the same trait from from
|
||||
// regex-automata, with some wording changed since we use this trait for
|
||||
|
16
src/dfa.rs
16
src/dfa.rs
@ -1,13 +1,13 @@
|
||||
use std::mem::size_of;
|
||||
|
||||
use ahocorasick::MatchKind;
|
||||
use automaton::Automaton;
|
||||
use classes::ByteClasses;
|
||||
use error::Result;
|
||||
use nfa::{PatternID, PatternLength, NFA};
|
||||
use prefilter::{Prefilter, PrefilterObj, PrefilterState};
|
||||
use state_id::{dead_id, fail_id, premultiply_overflow_error, StateID};
|
||||
use Match;
|
||||
use crate::ahocorasick::MatchKind;
|
||||
use crate::automaton::Automaton;
|
||||
use crate::classes::ByteClasses;
|
||||
use crate::error::Result;
|
||||
use crate::nfa::{PatternID, PatternLength, NFA};
|
||||
use crate::prefilter::{Prefilter, PrefilterObj, PrefilterState};
|
||||
use crate::state_id::{dead_id, fail_id, premultiply_overflow_error, StateID};
|
||||
use crate::Match;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum DFA<S> {
|
||||
|
@ -194,12 +194,12 @@ extern crate memchr;
|
||||
// #[cfg(doctest)]
|
||||
// doctest!("../README.md");
|
||||
|
||||
pub use ahocorasick::{
|
||||
pub use crate::ahocorasick::{
|
||||
AhoCorasick, AhoCorasickBuilder, FindIter, FindOverlappingIter, MatchKind,
|
||||
StreamFindIter,
|
||||
};
|
||||
pub use error::{Error, ErrorKind};
|
||||
pub use state_id::StateID;
|
||||
pub use crate::error::{Error, ErrorKind};
|
||||
pub use crate::state_id::StateID;
|
||||
|
||||
mod ahocorasick;
|
||||
mod automaton;
|
||||
|
14
src/nfa.rs
14
src/nfa.rs
@ -4,13 +4,13 @@ use std::fmt;
|
||||
use std::mem::size_of;
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
use ahocorasick::MatchKind;
|
||||
use automaton::Automaton;
|
||||
use classes::{ByteClassBuilder, ByteClasses};
|
||||
use error::Result;
|
||||
use prefilter::{self, opposite_ascii_case, Prefilter, PrefilterObj};
|
||||
use state_id::{dead_id, fail_id, usize_to_state_id, StateID};
|
||||
use Match;
|
||||
use crate::ahocorasick::MatchKind;
|
||||
use crate::automaton::Automaton;
|
||||
use crate::classes::{ByteClassBuilder, ByteClasses};
|
||||
use crate::error::Result;
|
||||
use crate::prefilter::{self, opposite_ascii_case, Prefilter, PrefilterObj};
|
||||
use crate::state_id::{dead_id, fail_id, usize_to_state_id, StateID};
|
||||
use crate::Match;
|
||||
|
||||
/// The identifier for a pattern, which is simply the position of the pattern
|
||||
/// in the sequence of patterns given by the caller.
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::u16;
|
||||
|
||||
use packed::pattern::Patterns;
|
||||
use packed::rabinkarp::RabinKarp;
|
||||
use packed::teddy::{self, Teddy};
|
||||
use Match;
|
||||
use crate::packed::pattern::Patterns;
|
||||
use crate::packed::rabinkarp::RabinKarp;
|
||||
use crate::packed::teddy::{self, Teddy};
|
||||
use crate::Match;
|
||||
|
||||
/// This is a limit placed on the total number of patterns we're willing to try
|
||||
/// and match at once. As more sophisticated algorithms are added, this number
|
||||
|
@ -105,7 +105,7 @@ common reasons:
|
||||
no searcher is built.
|
||||
*/
|
||||
|
||||
pub use packed::api::{Builder, Config, FindIter, MatchKind, Searcher};
|
||||
pub use crate::packed::api::{Builder, Config, FindIter, MatchKind, Searcher};
|
||||
|
||||
mod api;
|
||||
mod pattern;
|
||||
|
@ -4,7 +4,7 @@ use std::mem;
|
||||
use std::u16;
|
||||
use std::usize;
|
||||
|
||||
use packed::api::MatchKind;
|
||||
use crate::packed::api::MatchKind;
|
||||
|
||||
/// The type used for representing a pattern identifier.
|
||||
///
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::mem;
|
||||
|
||||
use packed::pattern::{PatternID, Patterns};
|
||||
use Match;
|
||||
use crate::packed::pattern::{PatternID, Patterns};
|
||||
use crate::Match;
|
||||
|
||||
/// The type of the rolling hash used in the Rabin-Karp algorithm.
|
||||
type Hash = usize;
|
||||
|
@ -4,8 +4,8 @@ use std::cmp;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
|
||||
use packed::pattern::{PatternID, Patterns};
|
||||
use packed::teddy::Teddy;
|
||||
use crate::packed::pattern::{PatternID, Patterns};
|
||||
use crate::packed::teddy::Teddy;
|
||||
|
||||
/// A builder for constructing a Teddy matcher.
|
||||
///
|
||||
@ -73,7 +73,7 @@ impl Builder {
|
||||
}
|
||||
|
||||
fn build_imp(&self, patterns: &Patterns) -> Option<Teddy> {
|
||||
use packed::teddy::runtime;
|
||||
use crate::packed::teddy::runtime;
|
||||
|
||||
// Most of the logic here is just about selecting the optimal settings,
|
||||
// or perhaps even rejecting construction altogether. The choices
|
||||
|
@ -1,11 +1,11 @@
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use packed::teddy::compile::Builder;
|
||||
pub use crate::packed::teddy::compile::Builder;
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
pub use packed::teddy::fallback::Builder;
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
pub use packed::teddy::fallback::Teddy;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use packed::teddy::runtime::Teddy;
|
||||
pub use crate::packed::teddy::runtime::Teddy;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod compile;
|
||||
|
@ -51,10 +51,10 @@
|
||||
use std::arch::x86_64::*;
|
||||
use std::mem;
|
||||
|
||||
use packed::pattern::{PatternID, Patterns};
|
||||
use packed::teddy::compile;
|
||||
use packed::vector::*;
|
||||
use Match;
|
||||
use crate::packed::pattern::{PatternID, Patterns};
|
||||
use crate::packed::teddy::compile;
|
||||
use crate::packed::vector::*;
|
||||
use crate::Match;
|
||||
|
||||
/// The Teddy runtime.
|
||||
///
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::usize;
|
||||
|
||||
use packed::{Config, MatchKind};
|
||||
use Match;
|
||||
use crate::packed::{Config, MatchKind};
|
||||
use crate::Match;
|
||||
|
||||
/// A description of a single test against a multi-pattern searcher.
|
||||
///
|
||||
|
@ -5,9 +5,9 @@ use std::u8;
|
||||
|
||||
use memchr::{memchr, memchr2, memchr3};
|
||||
|
||||
use ahocorasick::MatchKind;
|
||||
use packed;
|
||||
use Match;
|
||||
use crate::ahocorasick::MatchKind;
|
||||
use crate::packed;
|
||||
use crate::Match;
|
||||
|
||||
/// A candidate is the result of running a prefilter on a haystack at a
|
||||
/// particular position. The result is either no match, a confirmed match or
|
||||
@ -1032,7 +1032,7 @@ pub fn opposite_ascii_case(b: u8) -> u8 {
|
||||
/// Return the frequency rank of the given byte. The higher the rank, the more
|
||||
/// common the byte (heuristically speaking).
|
||||
fn freq_rank(b: u8) -> u8 {
|
||||
use byte_frequencies::BYTE_FREQUENCIES;
|
||||
use crate::byte_frequencies::BYTE_FREQUENCIES;
|
||||
BYTE_FREQUENCIES[b as usize]
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
|
||||
use error::{Error, Result};
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
// NOTE: Most of this code was copied from regex-automata, but without the
|
||||
// (de)serialization specific stuff.
|
||||
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
use std::io;
|
||||
use std::usize;
|
||||
|
||||
use {AhoCorasickBuilder, Match, MatchKind};
|
||||
use crate::{AhoCorasickBuilder, Match, MatchKind};
|
||||
|
||||
/// A description of a single test against an Aho-Corasick automaton.
|
||||
///
|
||||
@ -1129,7 +1129,7 @@ fn regression_ascii_case_insensitive_no_exponential() {
|
||||
// was incorrect, leading to a false negative.
|
||||
#[test]
|
||||
fn regression_rare_byte_prefilter() {
|
||||
use AhoCorasick;
|
||||
use crate::AhoCorasick;
|
||||
|
||||
let ac = AhoCorasick::new_auto_configured(&["ab/j/", "x/"]);
|
||||
assert!(ac.is_match("ab/j/"));
|
||||
@ -1137,7 +1137,7 @@ fn regression_rare_byte_prefilter() {
|
||||
|
||||
#[test]
|
||||
fn regression_case_insensitive_prefilter() {
|
||||
use AhoCorasickBuilder;
|
||||
use crate::AhoCorasickBuilder;
|
||||
|
||||
for c in b'a'..b'z' {
|
||||
for c2 in b'a'..b'z' {
|
||||
|
Loading…
Reference in New Issue
Block a user