diff --git a/Cargo.toml b/Cargo.toml index 296d46d..597201d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,13 +16,14 @@ repository = "https://github.com/leontoeides/indicium" maintenance = { status = "actively-developed" } [features] -default = [ "simple", "fuzzy" ] +default = [ "simple", "fuzzy", "ahash" ] simple = [] fuzzy = [ "strsim" ] +ahash = [ "dep:ahash" ] select2 = [ "simple", "serde" ] [dependencies] -ahash = "0.8" +ahash = { version = "0.8", optional = true } kstring = "2.0" serde = { version = "1.0", features = [ "derive" ], optional = true } strsim = { version = "0.10", optional = true } diff --git a/src/simple/insert.rs b/src/simple/insert.rs index e84495b..392a921 100644 --- a/src/simple/insert.rs +++ b/src/simple/insert.rs @@ -1,4 +1,10 @@ +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::HashSet; +#[cfg(not(feature = "ahash"))] +use std::collections::HashSet; + +// Static dependencies: use crate::simple::{indexable::Indexable, search_index::SearchIndex}; use kstring::KString; use std::collections::BTreeSet; diff --git a/src/simple/internal/indexable_keywords.rs b/src/simple/internal/indexable_keywords.rs index dbf7bdd..93f8f02 100644 --- a/src/simple/internal/indexable_keywords.rs +++ b/src/simple/internal/indexable_keywords.rs @@ -1,4 +1,10 @@ +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::HashSet; +#[cfg(not(feature = "ahash"))] +use std::collections::HashSet; + +// Static dependencies: use crate::simple::internal::string_keywords::SplitContext; use crate::simple::{Indexable, SearchIndex}; use kstring::KString; diff --git a/src/simple/internal/search_top_scores/mod.rs b/src/simple/internal/search_top_scores/mod.rs index bad18a4..bef31d1 100644 --- a/src/simple/internal/search_top_scores/mod.rs +++ b/src/simple/internal/search_top_scores/mod.rs @@ -9,7 +9,13 @@ mod with_capacity; // ----------------------------------------------------------------------------- +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::HashMap; +#[cfg(not(feature = "ahash"))] +use std::collections::HashMap; + +// Static dependencies: use std::{cmp::Ord, hash::Hash}; // ----------------------------------------------------------------------------- diff --git a/src/simple/internal/search_top_scores/with_capacity.rs b/src/simple/internal/search_top_scores/with_capacity.rs index c279d5c..e4aaf58 100644 --- a/src/simple/internal/search_top_scores/with_capacity.rs +++ b/src/simple/internal/search_top_scores/with_capacity.rs @@ -1,4 +1,10 @@ +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::{HashMap, HashMapExt}; +#[cfg(not(feature = "ahash"))] +use std::collections::HashMap; + +// Static dependencies: use crate::simple::internal::SearchTopScores; use std::{cmp::Ord, hash::Hash}; diff --git a/src/simple/internal/strsim_top_scores/mod.rs b/src/simple/internal/strsim_top_scores/mod.rs index fef3830..7f93b92 100644 --- a/src/simple/internal/strsim_top_scores/mod.rs +++ b/src/simple/internal/strsim_top_scores/mod.rs @@ -9,7 +9,13 @@ mod with_capacity; // ----------------------------------------------------------------------------- +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::HashMap; +#[cfg(not(feature = "ahash"))] +use std::collections::HashMap; + +// Static dependencies: use kstring::KString; use std::collections::BTreeSet; use std::{cmp::Ord, cmp::PartialOrd, hash::Hash}; diff --git a/src/simple/internal/strsim_top_scores/with_capacity.rs b/src/simple/internal/strsim_top_scores/with_capacity.rs index 6287bed..29e4451 100644 --- a/src/simple/internal/strsim_top_scores/with_capacity.rs +++ b/src/simple/internal/strsim_top_scores/with_capacity.rs @@ -1,4 +1,10 @@ +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::{HashMap, HashMapExt}; +#[cfg(not(feature = "ahash"))] +use std::collections::HashMap; + +// Static dependencies: use crate::simple::internal::StrsimTopScores; use std::{cmp::Ord, cmp::PartialOrd, hash::Hash}; diff --git a/src/simple/remove.rs b/src/simple/remove.rs index 810342c..29f3f34 100644 --- a/src/simple/remove.rs +++ b/src/simple/remove.rs @@ -1,4 +1,10 @@ +// Conditionally select hash map type based on feature flags: +#[cfg(feature = "ahash")] use ahash::HashSet; +#[cfg(not(feature = "ahash"))] +use std::collections::HashSet; + +// Static dependencies: use crate::simple::{indexable::Indexable, search_index::SearchIndex}; use kstring::KString; use std::{clone::Clone, cmp::Ord};