Skip to content

Commit

Permalink
Keep the lock close to the operation requiring it
Browse files Browse the repository at this point in the history
This is only for readability and is unlikely to make a difference to the
compiled code.
  • Loading branch information
jedisct1 committed Nov 10, 2016
1 parent 9384f3b commit 62ce91d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ impl Cache {
let now = Instant::now();
let duration = Duration::from_secs(ttl as u64);
let expiration = now + duration;
let mut cache = self.arc_mx.lock().unwrap();
let cache_entry = CacheEntry {
expiration: expiration,
packet: packet,
};
let mut cache = self.arc_mx.lock().unwrap();
cache.insert(normalized_question_key, cache_entry)
}

Expand Down

0 comments on commit 62ce91d

Please sign in to comment.