Make gAliases be just an array of ids. (Bug 849656, patch 4) r=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Wed, 13 Mar 2013 09:58:39 -0700
changeset 124682 8d62f3d758b7417d9910ea68bb3fff6f8dae81be
parent 124681 c3b5d2b711527bb399bca000d5f6260169ec05f1
child 124683 f5f4ef33fa067bb4a3ffaa4031b476767d7ace58
push id24545
push userdbaron@mozilla.com
push dateWed, 13 Mar 2013 16:59:08 +0000
treeherdermozilla-inbound@f5f4ef33fa06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs849656
milestone22.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
Make gAliases be just an array of ids. (Bug 849656, patch 4) r=bzbarsky
layout/style/nsCSSProps.cpp
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -78,24 +78,20 @@ SortPropertyAndCount(const void* s1, con
 }
 
 // We need eCSSAliasCount so we can make gAliases nonzero size when there
 // are no aliases.
 enum {
   eCSSAliasCount = eCSSProperty_COUNT_with_aliases - eCSSProperty_COUNT
 };
 
-struct CSSPropertyAlias {
-  const nsCSSProperty id;
-};
-
 // The names are in kCSSRawProperties.
-static CSSPropertyAlias gAliases[eCSSAliasCount != 0 ? eCSSAliasCount : 1] = {
+static nsCSSProperty gAliases[eCSSAliasCount != 0 ? eCSSAliasCount : 1] = {
 #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)  \
-  { eCSSProperty_##propid_ },
+  eCSSProperty_##propid_ ,
 #include "nsCSSPropAliasList.h"
 #undef CSS_PROP_ALIAS
 };
 
 void
 nsCSSProps::AddRefTable(void)
 {
   if (0 == gTableRefCount++) {
@@ -357,19 +353,20 @@ nsCSSProps::LookupProperty(const nsACStr
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
 
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
   // Check eCSSAliasCount against 0 to make it easy for the
   // compiler to optimize away the 0-aliases case.
   if (eCSSAliasCount != 0 && res >= eCSSProperty_COUNT) {
     MOZ_STATIC_ASSERT(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
                       "assuming eCSSProperty_UNKNOWN doesn't hit this code");
-    const CSSPropertyAlias &alias = gAliases[res - eCSSProperty_COUNT];
     if (IsEnabled(res) || aEnabled == eAny) {
-      res = alias.id;
+      res = gAliases[res - eCSSProperty_COUNT];
+      NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
+                        "aliases must not point to other aliases");
     } else {
       res = eCSSProperty_UNKNOWN;
     }
   }
   if (res != eCSSProperty_UNKNOWN && aEnabled == eEnabled && !IsEnabled(res)) {
     res = eCSSProperty_UNKNOWN;
   }
   return res;
@@ -383,19 +380,20 @@ nsCSSProps::LookupProperty(const nsAStri
   // converting and avoid a PromiseFlatCString() call.
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
   // Check eCSSAliasCount against 0 to make it easy for the
   // compiler to optimize away the 0-aliases case.
   if (eCSSAliasCount != 0 && res >= eCSSProperty_COUNT) {
     MOZ_STATIC_ASSERT(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
                       "assuming eCSSProperty_UNKNOWN doesn't hit this code");
-    const CSSPropertyAlias &alias = gAliases[res - eCSSProperty_COUNT];
     if (IsEnabled(res) || aEnabled == eAny) {
-      res = alias.id;
+      res = gAliases[res - eCSSProperty_COUNT];
+      NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
+                        "aliases must not point to other aliases");
     } else {
       res = eCSSProperty_UNKNOWN;
     }
   }
   if (res != eCSSProperty_UNKNOWN && aEnabled == eEnabled && !IsEnabled(res)) {
     res = eCSSProperty_UNKNOWN;
   }
   return res;