Skip to content

Commit

Permalink
ahash is now an optional feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
leontoeides committed Oct 10, 2023
1 parent b242587 commit b16a971
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 6 additions & 0 deletions src/simple/insert.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/simple/internal/indexable_keywords.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/simple/internal/search_top_scores/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

// -----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/simple/internal/search_top_scores/with_capacity.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
6 changes: 6 additions & 0 deletions src/simple/internal/strsim_top_scores/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 6 additions & 0 deletions src/simple/internal/strsim_top_scores/with_capacity.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
6 changes: 6 additions & 0 deletions src/simple/remove.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down

0 comments on commit b16a971

Please sign in to comment.