Bug 1428053: Use Maybe<uint32_t> instead of an integer and a bool. r=jessica
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 04 Jan 2018 16:47:29 +0100
changeset 449712 638e6870de94b61e062c7815045397765162f40a
parent 449711 4a7086f02b605337d91e9ca877faec138c83c02a
child 449713 07467c83fe96babaca416268fc6ae2128d55cf98
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjessica
bugs1428053
milestone59.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 1428053: Use Maybe<uint32_t> instead of an integer and a bool. r=jessica This is just cleanup and not needed, but I wrote it while debugging so I'd rather land it :) MozReview-Commit-ID: BdnheDnwHr4
dom/base/ShadowRoot.cpp
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -351,37 +351,36 @@ ShadowRoot::AssignSlotFor(nsIContent* aC
 
   HTMLSlotElement* slot = slots->ElementAt(0);
   MOZ_ASSERT(slot);
 
   // Find the appropriate position in the assigned node list for the
   // newly assigned content.
   const nsTArray<RefPtr<nsINode>>& assignedNodes = slot->AssignedNodes();
   nsIContent* currentContent = GetHost()->GetFirstChild();
-  bool indexFound = false;
-  uint32_t insertionIndex;
+  Maybe<uint32_t> insertionIndex;
   for (uint32_t i = 0; i < assignedNodes.Length(); i++) {
     // Seek through the host's explicit children until the
     // assigned content is found.
     while (currentContent && currentContent != assignedNodes[i]) {
       if (currentContent == aContent) {
-        indexFound = true;
-        insertionIndex = i;
+        insertionIndex.emplace(i);
+        break;
       }
 
       currentContent = currentContent->GetNextSibling();
     }
 
-    if (indexFound) {
+    if (insertionIndex) {
       break;
     }
   }
 
-  if (indexFound) {
-    slot->InsertAssignedNode(insertionIndex, aContent);
+  if (insertionIndex) {
+    slot->InsertAssignedNode(*insertionIndex, aContent);
   } else {
     slot->AppendAssignedNode(aContent);
   }
 
   return slot;
 }
 
 const HTMLSlotElement*