Bug 1193762 part 4 - Avoid nsCOMPtr in ternary operator; r=froydnj
authorAryeh Gregor <ayg@aryeh.name>
Sun, 01 May 2016 21:29:22 +0300
changeset 295680 fb8c79c89d066a07c24e91cf5883c73bbeaf1832
parent 295679 13a690e057e72e537f983cef9b888a17a4b64a43
child 295681 3d3cc3ecdca6c6de7b69c34a551bd8f61b903a97
push id19015
push usercbook@mozilla.com
push dateMon, 02 May 2016 09:39:23 +0000
treeherderfx-team@2080375bc69d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1193762
milestone49.0a1
Bug 1193762 part 4 - Avoid nsCOMPtr in ternary operator; r=froydnj
dom/base/ImportManager.h
dom/base/ScriptSettings.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsXMLHttpRequest.cpp
editor/libeditor/nsEditorEventListener.cpp
js/xpconnect/src/XPCMaps.h
layout/generic/nsPluginFrame.h
--- a/dom/base/ImportManager.h
+++ b/dom/base/ImportManager.h
@@ -154,28 +154,34 @@ public:
   {
     return mDocument;
   }
 
   // Getter for the import document that is used in the spec. Returns
   // nullptr if the import is not yet ready.
   nsIDocument* GetImport()
   {
-    return mReady ? mDocument : nullptr;
+    if (!mReady) {
+      return nullptr;
+    }
+    return mDocument;
   }
 
   // There is only one referring link that is marked as primary link per
   // imports. This is the one that has to be taken into account when
   // scrip execution order is determined. Links marked as primary link form
   // a spanning tree in the import graph. (Eliminating the cycles and
   // multiple parents.) This spanning tree is recalculated every time
   // a new import link is added to the manager.
   nsINode* GetMainReferrer()
   {
-    return mLinks.IsEmpty() ? nullptr : mLinks[mMainReferrer];
+    if (mLinks.IsEmpty()) {
+      return nullptr;
+    }
+    return mLinks[mMainReferrer];
   }
 
   // An import is not only blocked by its import children, but also
   // by its predecessors. It's enough to find the closest predecessor
   // and wait for that to run its scripts. We keep track of all the
   // ScriptRunners that are waiting for this import. NOTE: updating
   // the main referrer might change this list.
   void AddBlockedScriptLoader(nsScriptLoader* aScriptLoader);
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -47,17 +47,20 @@ public:
 
   static void Pop(ScriptSettingsStackEntry *aEntry) {
     MOZ_ASSERT(aEntry == Top());
     sScriptSettingsTLS.set(aEntry->mOlder);
   }
 
   static nsIGlobalObject* IncumbentGlobal() {
     ScriptSettingsStackEntry *entry = Top();
-    return entry ? entry->mGlobalObject : nullptr;
+    if (!entry) {
+      return nullptr;
+    }
+    return entry->mGlobalObject;
   }
 
   static ScriptSettingsStackEntry* EntryPoint() {
     ScriptSettingsStackEntry *entry = Top();
     if (!entry) {
       return nullptr;
     }
     while (entry) {
@@ -65,17 +68,20 @@ public:
         return entry;
       entry = entry->mOlder;
     }
     MOZ_CRASH("Non-empty stack should always have an entry point");
   }
 
   static nsIGlobalObject* EntryGlobal() {
     ScriptSettingsStackEntry *entry = EntryPoint();
-    return entry ? entry->mGlobalObject : nullptr;
+    if (!entry) {
+      return nullptr;
+    }
+    return entry->mGlobalObject;
   }
 
 };
 
 static unsigned long gRunToCompletionListeners = 0;
 
 void
 UseEntryScriptProfiling()
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2080,17 +2080,20 @@ nsGlobalWindow::EnsureScriptEnvironment(
   outer->mContext = context;
   return NS_OK;
 }
 
 nsIScriptContext *
 nsGlobalWindow::GetScriptContext()
 {
   nsGlobalWindow* outer = GetOuterWindowInternal();
-  return outer ? outer->mContext : nullptr;
+  if (!outer) {
+    return nullptr;
+  }
+  return outer->mContext;
 }
 
 JSObject *
 nsGlobalWindow::GetGlobalJSObject()
 {
   return FastGetGlobalJSObject();
 }
 
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -543,17 +543,20 @@ nsXMLHttpRequest::GetResponseXML(ErrorRe
       mResponseType != XML_HTTP_RESPONSE_TYPE_DOCUMENT) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
   if (mWarnAboutSyncHtml) {
     mWarnAboutSyncHtml = false;
     LogMessage("HTMLSyncXHRWarning", GetOwner());
   }
-  return (XML_HTTP_REQUEST_DONE & mState) ? mResponseXML : nullptr;
+  if (!(XML_HTTP_REQUEST_DONE & mState)) {
+    return nullptr;
+  }
+  return mResponseXML;
 }
 
 /*
  * This piece copied from XMLDocument, we try to get the charset
  * from HTTP headers.
  */
 nsresult
 nsXMLHttpRequest::DetectCharset()
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -319,17 +319,21 @@ nsEditorEventListener::GetFocusedRootCon
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
   if (!focusedContent) {
     return nullptr;
   }
 
   nsIDocument* composedDoc = focusedContent->GetComposedDoc();
   NS_ENSURE_TRUE(composedDoc, nullptr);
 
-  return composedDoc->HasFlag(NODE_IS_EDITABLE) ? nullptr : focusedContent;
+  if (composedDoc->HasFlag(NODE_IS_EDITABLE)) {
+    return nullptr;
+  }
+
+  return focusedContent;
 }
 
 bool
 nsEditorEventListener::EditorHasFocus()
 {
   NS_PRECONDITION(mEditor,
     "The caller must check whether this is connected to an editor");
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -460,17 +460,20 @@ public:
         static const struct PLDHashTableOps sOps;
     };
 
     static IID2ThisTranslatorMap* newMap(int length);
 
     inline nsIXPCFunctionThisTranslator* Find(REFNSIID iid)
     {
         auto entry = static_cast<Entry*>(mTable.Search(&iid));
-        return entry ? entry->value : nullptr;
+        if (!entry) {
+            return nullptr;
+        }
+        return entry->value;
     }
 
     inline nsIXPCFunctionThisTranslator* Add(REFNSIID iid,
                                              nsIXPCFunctionThisTranslator* obj)
     {
         auto entry = static_cast<Entry*>(mTable.Add(&iid, mozilla::fallible));
         if (!entry)
             return nullptr;
--- a/layout/generic/nsPluginFrame.h
+++ b/layout/generic/nsPluginFrame.h
@@ -186,17 +186,22 @@ public:
    */
   static void BeginSwapDocShells(nsISupports* aSupports, void*);
   /**
    * If aSupports has a nsPluginFrame, then set it up after a DocShell swap.
    * @see nsSubDocumentFrame::EndSwapDocShells.
    */
   static void EndSwapDocShells(nsISupports* aSupports, void*);
 
-  nsIWidget* GetWidget() override { return mInnerView ? mWidget : nullptr; }
+  nsIWidget* GetWidget() override {
+    if (!mInnerView) {
+      return nullptr;
+    }
+    return mWidget;
+  }
 
   /**
    * Adjust the plugin's idea of its size, using aSize as its new size.
    * (aSize must be in twips)
    */
   void FixupWindow(const nsSize& aSize);
 
   /*