Bug 1684673 - Reorder some conditions when handling class/part attributes. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Jan 2021 04:50:01 +0000
changeset 561817 0a114ac95a422d422fe6ce991502c78f480fdb81
parent 561816 6aee4144bf6bfa778452a3f852fe07970ab75c43
child 561818 87dc458116789fe1bf79a9765aaf025f7d091e41
push id38071
push usernerli@mozilla.com
push dateSun, 03 Jan 2021 09:29:41 +0000
treeherdermozilla-central@1098ab162ad2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1684673
milestone86.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
Bug 1684673 - Reorder some conditions when handling class/part attributes. r=xidorn Empty class attributes are uncommon. Differential Revision: https://phabricator.services.mozilla.com/D100592
servo/components/style/gecko/snapshot_helpers.rs
--- a/servo/components/style/gecko/snapshot_helpers.rs
+++ b/servo/components/style/gecko/snapshot_helpers.rs
@@ -29,37 +29,36 @@ fn base_type(attr: &structs::nsAttrValue
 unsafe fn ptr<T>(attr: &structs::nsAttrValue) -> *const T {
     (attr.mBits & !structs::NS_ATTRVALUE_BASETYPE_MASK) as *const T
 }
 
 #[inline(always)]
 unsafe fn get_class_or_part_from_attr(attr: &structs::nsAttrValue) -> Class {
     debug_assert!(bindings::Gecko_AssertClassAttrValueIsSane(attr));
     let base_type = base_type(attr);
-    if base_type == structs::nsAttrValue_ValueBaseType_eStringBase {
-        return Class::None;
-    }
     if base_type == structs::nsAttrValue_ValueBaseType_eAtomBase {
         return Class::One(ptr::<nsAtom>(attr));
     }
-    debug_assert_eq!(base_type, structs::nsAttrValue_ValueBaseType_eOtherBase);
-
-    let container = ptr::<structs::MiscContainer>(attr);
-    debug_assert_eq!(
-        (*container).mType,
-        structs::nsAttrValue_ValueType_eAtomArray
-    );
-    let array = (*container)
-        .__bindgen_anon_1
-        .mValue
-        .as_ref()
-        .__bindgen_anon_1
-        .mAtomArray
-        .as_ref();
-    Class::More(&***array)
+    if base_type == structs::nsAttrValue_ValueBaseType_eOtherBase {
+        let container = ptr::<structs::MiscContainer>(attr);
+        debug_assert_eq!(
+            (*container).mType,
+            structs::nsAttrValue_ValueType_eAtomArray
+        );
+        let array = (*container)
+            .__bindgen_anon_1
+            .mValue
+            .as_ref()
+            .__bindgen_anon_1
+            .mAtomArray
+            .as_ref();
+        return Class::More(&***array)
+    }
+    debug_assert_eq!(base_type, structs::nsAttrValue_ValueBaseType_eStringBase);
+    Class::None
 }
 
 #[inline(always)]
 unsafe fn get_id_from_attr(attr: &structs::nsAttrValue) -> &WeakAtom {
     debug_assert_eq!(
         base_type(attr),
         structs::nsAttrValue_ValueBaseType_eAtomBase
     );