Skip to content

Commit

Permalink
Use FxHash for faster entry hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
zbraniecki committed Jan 22, 2021
1 parent 6d5855e commit b16ab3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions fluent-bundle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ouroboros = "0.7"
smallvec = "1"
unic-langid = "0.9"
intl-memoizer = { version = "0.5", path = "../intl-memoizer" }
rustc-hash = "1"

[dev-dependencies]
criterion = "0.3"
Expand Down
7 changes: 4 additions & 3 deletions fluent-bundle/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

use std::borrow::Borrow;
use std::borrow::Cow;
use std::collections::hash_map::{Entry as HashEntry, HashMap};
use rustc_hash::FxHashMap;
use std::collections::hash_map::Entry as HashEntry;
use std::default::Default;
use std::fmt;

Expand All @@ -31,7 +32,7 @@ use crate::types::FluentValue;
pub struct FluentBundleBase<R, M> {
pub locales: Vec<LanguageIdentifier>,
pub(crate) resources: Vec<R>,
pub(crate) entries: HashMap<String, Entry>,
pub(crate) entries: FxHashMap<String, Entry>,
pub(crate) intls: M,
pub(crate) use_isolating: bool,
pub(crate) transform: Option<fn(&str) -> Cow<str>>,
Expand Down Expand Up @@ -64,7 +65,7 @@ impl<R, M: MemoizerKind> FluentBundleBase<R, M> {
Self {
locales,
resources: vec![],
entries: HashMap::new(),
entries: FxHashMap::default(),
intls: M::new(first_locale),
use_isolating: true,
transform: None,
Expand Down

0 comments on commit b16ab3a

Please sign in to comment.