From ed87fcf6cfc692f316ecdd4752998ad567193e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 25 Dec 2016 17:39:26 +0100 Subject: [PATCH] profile: Simplify profiler's find or insert code. --- components/profile/time.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/components/profile/time.rs b/components/profile/time.rs index 8cb7c9502c3..c246aabee1b 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -296,12 +296,7 @@ impl Profiler { } fn find_or_insert(&mut self, k: (ProfilerCategory, Option), t: f64) { - match self.buckets.get_mut(&k) { - None => {}, - Some(v) => { v.push(t); return; }, - } - - self.buckets.insert(k, vec!(t)); + self.buckets.entry(k).or_insert_with(Vec::new).push(t); } fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {