servo: Merge #18428 - style: remove selector_map::find_push (from emilio:find-push); r=nox
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 09 Sep 2017 07:56:35 -0500
changeset 429393 e49627fdbf67dffd50ffc7a0febf1fd5f34c3819
parent 429392 76eda7d1476e9a1937d6e77a8ef8aea005ba43f2
child 429394 27b589b9c3f465a64b416b61ff11d9cf23ae5f84
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
bugs18428
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18428 - style: remove selector_map::find_push (from emilio:find-push); r=nox It has a single caller and is overly generic, which is going to make harder to add fallible allocations to it. Source-Repo: https://github.com/servo/servo Source-Revision: 91b748ec22a952063c9e00870d4a788bc3799a18
servo/components/style/selector_map.rs
--- a/servo/components/style/selector_map.rs
+++ b/servo/components/style/selector_map.rs
@@ -294,17 +294,20 @@ impl<T: SelectorMapEntry> SelectorMap<T>
                 // html document (in which case we match against lower_name) or
                 // not (in which case we match against name).
                 //
                 // In the case of a non-html-element-in-html-document with a
                 // lowercase localname and a non-lowercase selector, the
                 // rulehash lookup may produce superfluous selectors, but the
                 // subsequent selector matching work will filter them out.
                 if name != lower_name {
-                    find_push(&mut self.local_name_hash, lower_name.clone(), entry.clone());
+                    self.local_name_hash
+                        .entry(lower_name.clone())
+                        .or_insert_with(SmallVec::new)
+                        .push(entry.clone());
                 }
                 self.local_name_hash
                     .entry(name.clone())
                     .or_insert_with(SmallVec::new)
             }
             Bucket::Universal => {
                 &mut self.other
             }
@@ -480,25 +483,16 @@ fn find_bucket<'a>(mut iter: SelectorIte
         if iter.next_sequence() != Some(Combinator::PseudoElement) {
             break;
         }
     }
 
     return current_bucket
 }
 
-#[inline]
-fn find_push<Str: Eq + Hash, V, VL>(map: &mut PrecomputedHashMap<Str, VL>,
-                                    key: Str,
-                                    value: V)
-    where VL: VecLike<V> + Default
-{
-    map.entry(key).or_insert_with(VL::default).push(value)
-}
-
 /// Wrapper for PrecomputedHashMap that does ASCII-case-insensitive lookup in quirks mode.
 #[derive(Debug)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct MaybeCaseInsensitiveHashMap<K: PrecomputedHash + Hash + Eq, V: 'static>(PrecomputedHashMap<K, V>);
 
 // FIXME(Manishearth) the 'static bound can be removed when
 // our HashMap fork (hashglobe) is able to use NonZero,
 // or when stdlib gets fallible collections