Skip to content

Commit 65c6bee

Browse files
committed
Bug 1445302 - Replace TArray.RemoveElementAt(TArray.Length() - 1) pattern with TArray.RemoveLastElement() or TArray.PopLastElement() r=froydnj
MozReview-Commit-ID: rGjabnP2iz --HG-- extra : rebase_source : 1ef6c5ce028ac9ebd9f3176d57835c43fe46bada
1 parent 1983e0d commit 65c6bee

39 files changed

+47
-63
lines changed

accessible/base/TreeWalker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree
345345
dom::AllChildrenIterator*
346346
TreeWalker::PopState()
347347
{
348-
size_t length = mStateStack.Length();
349-
mStateStack.RemoveElementAt(length - 1);
348+
mStateStack.RemoveLastElement();
350349
return mStateStack.IsEmpty() ? nullptr : &mStateStack.LastElement();
351350
}

dom/animation/KeyframeUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ HandleMissingFinalKeyframe(nsTArray<AnimationProperty>& aResult,
11881188
// If we have already appended a new entry for the property so we have to
11891189
// remove it.
11901190
if (aCurrentAnimationProperty) {
1191-
aResult.RemoveElementAt(aResult.Length() - 1);
1191+
aResult.RemoveLastElement();
11921192
}
11931193
return;
11941194
}

dom/base/TimeoutManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ TimeoutManager::DestroyFiringId(uint32_t aFiringId)
156156
{
157157
MOZ_DIAGNOSTIC_ASSERT(!mFiringIdStack.IsEmpty());
158158
MOZ_DIAGNOSTIC_ASSERT(mFiringIdStack.LastElement() == aFiringId);
159-
mFiringIdStack.RemoveElementAt(mFiringIdStack.Length() - 1);
159+
mFiringIdStack.RemoveLastElement();
160160
}
161161

162162
bool

dom/base/nsDocumentEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ nsDocumentEncoder::SerializeRangeContextEnd(nsAString& aString)
823823
break;
824824
}
825825

826-
mRangeContexts.RemoveElementAt(mRangeContexts.Length() - 1);
826+
mRangeContexts.RemoveLastElement();
827827
return rv;
828828
}
829829

dom/base/nsFrameMessageManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
11051105
StructuredCloneData* data = aRetVal->AppendElement();
11061106
data->Write(cx, rval, rv);
11071107
if (NS_WARN_IF(rv.Failed())) {
1108-
aRetVal->RemoveElementAt(aRetVal->Length() - 1);
1108+
aRetVal->RemoveLastElement();
11091109
nsString msg = aMessage + NS_LITERAL_STRING(": message reply cannot be cloned. Are you trying to send an XPCOM object?");
11101110

11111111
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));

dom/base/nsHTMLContentSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ nsHTMLContentSerializer::AppendElementEnd(Element* aElement, nsAString& aStr)
328328
/* Though at this point we must always have an state to be deleted as all
329329
the OL opening tags are supposed to push an olState object to the stack*/
330330
if (!mOLStateStack.IsEmpty()) {
331-
mOLStateStack.RemoveElementAt(mOLStateStack.Length() -1);
331+
mOLStateStack.RemoveLastElement();
332332
}
333333
}
334334

dom/base/nsXHTMLContentSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ nsXHTMLContentSerializer::CheckElementEnd(mozilla::dom::Element* aElement,
455455
/* Though at this point we must always have an state to be deleted as all
456456
the OL opening tags are supposed to push an olState object to the stack*/
457457
if (!mOLStateStack.IsEmpty()) {
458-
mOLStateStack.RemoveElementAt(mOLStateStack.Length() -1);
458+
mOLStateStack.RemoveLastElement();
459459
}
460460
}
461461

dom/canvas/CanvasRenderingContext2D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ CanvasRenderingContext2D::Restore()
22402240
}
22412241
}
22422242

2243-
mStyleStack.RemoveElementAt(mStyleStack.Length() - 1);
2243+
mStyleStack.RemoveLastElement();
22442244

22452245
mTarget->SetTransform(CurrentState().transform);
22462246
}

dom/media/webrtc/MediaTrackConstraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ MediaConstraintsHelper::SelectSettings(
531531
}
532532
if (aDevices.IsEmpty()) {
533533
aDevices.AppendElements(Move(rejects));
534-
aggregateConstraints.RemoveElementAt(aggregateConstraints.Length() - 1);
534+
aggregateConstraints.RemoveLastElement();
535535
}
536536
}
537537
return nullptr;

dom/workers/WorkerLoadInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ InterfaceRequestor::GetAnyLiveTabChild()
529529
}
530530

531531
// Otherwise remove the stale weak reference and check the next one
532-
mTabChildList.RemoveElementAt(mTabChildList.Length() - 1);
532+
mTabChildList.RemoveLastElement();
533533
}
534534

535535
return nullptr;

0 commit comments

Comments
 (0)