diff --git a/src/ftrl.rs b/src/ftrl.rs index 960fc70..818c3bd 100644 --- a/src/ftrl.rs +++ b/src/ftrl.rs @@ -27,9 +27,9 @@ impl FTRL { beta, lambda1, lambda2, - z: HashMap::new(), - n: HashMap::new(), - weights: HashMap::new(), + z: HashMap::with_capacity(8192), + n: HashMap::with_capacity(8192), + weights: HashMap::with_capacity(8192), } } diff --git a/src/identifiers.rs b/src/identifiers.rs index daebfdc..42ccf15 100644 --- a/src/identifiers.rs +++ b/src/identifiers.rs @@ -104,8 +104,8 @@ impl Identifier { Self { name: name.to_string(), pass_through: None, - obj_to_id: HashMap::new(), - id_to_obj: Vec::new(), + obj_to_id: HashMap::with_capacity(8192), + id_to_obj: Vec::with_capacity(8192), } } diff --git a/src/interactions.rs b/src/interactions.rs index 561baa3..fe5c969 100644 --- a/src/interactions.rs +++ b/src/interactions.rs @@ -19,8 +19,8 @@ impl UserItemInteractions { let decay_rate = decay_in_days.map(|days| 1.0 - (E.ln() / days)); UserItemInteractions { - interactions: HashMap::new(), - all_item_ids: HashSet::new(), + interactions: HashMap::with_capacity(8192), + all_item_ids: HashSet::with_capacity(8192), min_value, max_value, decay_rate,