Skip to content

Commit

Permalink
[perf] Better hash for CounterKey
Browse files Browse the repository at this point in the history
  • Loading branch information
didierofrivia committed Jun 26, 2023
1 parent ae0084c commit 1452117
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions limitador/src/storage/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ impl From<&mut Counter> for CounterKey {

impl Hash for CounterKey {
fn hash<H: Hasher>(&self, state: &mut H) {
let mut encoded_vars = self
.set_variables
.iter()
.map(|(k, v)| k.to_owned() + ":" + v)
.collect::<Vec<String>>();

encoded_vars.sort();
encoded_vars.hash(state);
self.set_variables.iter().for_each(|(k, v)| {
k.hash(state);
v.hash(state);
});
}
}

Expand Down

0 comments on commit 1452117

Please sign in to comment.