Skip to content

Commit

Permalink
[refactor] Removing normalizing step
Browse files Browse the repository at this point in the history
* Not needed anymore since counters are normalized when limits are
  created
  • Loading branch information
didierofrivia committed Aug 11, 2023
1 parent b2e9ab8 commit c96f478
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions limitador/src/storage/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl CounterStorage for InMemoryStorage {
delta: i64,
load_counters: bool,
) -> Result<Authorization, StorageErr> {
let mut limits_by_namespace = self.limits_for_namespace.write().unwrap();
let limits_by_namespace = self.limits_for_namespace.write().unwrap();
let mut first_limited = None;
let mut counter_values_to_update: Vec<(&AtomicExpiringValue, u64)> = Vec::new();
let mut qualified_counter_values_to_updated: Vec<(Arc<AtomicExpiringValue>, u64)> =
Expand All @@ -122,15 +122,6 @@ impl CounterStorage for InMemoryStorage {
None
};

// Normalize counters and values
for counter in counters.iter().filter(|c| !c.is_qualified()) {
limits_by_namespace
.entry(counter.limit().namespace().clone())
.or_insert_with(HashMap::new)
.entry(counter.limit().clone())
.or_insert_with(AtomicExpiringValue::default);
}

// Process simple counters
for counter in counters.iter_mut().filter(|c| !c.is_qualified()) {
let atomic_expiring_value: &AtomicExpiringValue = limits_by_namespace
Expand Down

0 comments on commit c96f478

Please sign in to comment.