Bug 1449787 - Reduce indirection for static pointers in nsMediaFeature. r=emilio
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 26 Apr 2018 13:28:26 +1000
changeset 495337 77803e121c8f469e2044e5ade6bc6c37f9a55052
parent 495336 4c3191c16f0a69be922e6b5c66386fc2ad9e0fb1
child 495338 66b689d8aa4d337e43e4253abd88e5bcceeeca99
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1449787
milestone64.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 1449787 - Reduce indirection for static pointers in nsMediaFeature. r=emilio The patch also changes sSystemMetrics to not refcount its elements, because static atoms don't need refcounting. MozReview-Commit-ID: 7uf7YjyNaZp
layout/style/nsMediaFeatures.cpp
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -20,29 +20,29 @@
 #include "nsIDocument.h"
 #include "nsIWidget.h"
 #include "nsContentUtils.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 
 using namespace mozilla;
 
-static nsTArray<RefPtr<nsAtom>>* sSystemMetrics = nullptr;
+static nsTArray<const nsStaticAtom*>* sSystemMetrics = nullptr;
 
 #ifdef XP_WIN
 struct OperatingSystemVersionInfo {
   LookAndFeel::OperatingSystemVersion mId;
-  nsStaticAtom** mName;
+  nsStaticAtom* const mName;
 };
 
 // Os version identities used in the -moz-os-version media query.
 const OperatingSystemVersionInfo kOsVersionStrings[] = {
-  { LookAndFeel::eOperatingSystemVersion_Windows7,  &nsGkAtoms::windows_win7 },
-  { LookAndFeel::eOperatingSystemVersion_Windows8,  &nsGkAtoms::windows_win8 },
-  { LookAndFeel::eOperatingSystemVersion_Windows10, &nsGkAtoms::windows_win10 }
+  { LookAndFeel::eOperatingSystemVersion_Windows7,  nsGkAtoms::windows_win7 },
+  { LookAndFeel::eOperatingSystemVersion_Windows8,  nsGkAtoms::windows_win8 },
+  { LookAndFeel::eOperatingSystemVersion_Windows10, nsGkAtoms::windows_win10 }
 };
 #endif
 
 // A helper for four features below
 static nsSize
 GetSize(nsIDocument* aDocument)
 {
   nsPresContext* pc = aDocument->GetPresContext();
@@ -239,17 +239,17 @@ Gecko_MediaFeatures_GetOperatingSystemVe
 
 #ifdef XP_WIN
   int32_t metricResult;
   if (NS_SUCCEEDED(
         LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier,
                             &metricResult))) {
     for (const auto& osVersion : kOsVersionStrings) {
       if (metricResult == osVersion.mId) {
-        return *osVersion.mName;
+        return osVersion.mName;
       }
     }
   }
 #endif
 
   return nullptr;
 }
 
@@ -302,17 +302,17 @@ Gecko_MediaFeatures_AllPointerCapabiliti
 /* static */ void
 nsMediaFeatures::InitSystemMetrics()
 {
   if (sSystemMetrics)
     return;
 
   MOZ_ASSERT(NS_IsMainThread());
 
-  sSystemMetrics = new nsTArray<RefPtr<nsAtom>>;
+  sSystemMetrics = new nsTArray<const nsStaticAtom*>;
 
   /***************************************************************************
    * ANY METRICS ADDED HERE SHOULD ALSO BE ADDED AS MEDIA QUERIES BELOW      *
    ***************************************************************************/
 
   int32_t metricResult =
     LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollArrowStyle);
   if (metricResult & LookAndFeel::eScrollArrow_StartBackward) {