From 35a9dea37ae81b35520a9548ca3cbf3064f990a0 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Wed, 29 Sep 2021 07:24:43 +0000 Subject: [PATCH] Bug 1729329 - Mark txList::insertBefore as infallible. r=farre Differential Revision: https://phabricator.services.mozilla.com/D124675 --- dom/xslt/base/txList.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/dom/xslt/base/txList.cpp b/dom/xslt/base/txList.cpp index ce5386b6cb24..a361490784dc 100644 --- a/dom/xslt/base/txList.cpp +++ b/dom/xslt/base/txList.cpp @@ -25,7 +25,7 @@ txList::txList() { */ txList::~txList() { clear(); } //-- ~txList -void txList::add(void* objPtr) { insertBefore(objPtr, 0); } //-- add +void txList::add(void* objPtr) { insertBefore(objPtr, nullptr); } //-- add /** * Returns the number of items in this txList @@ -40,12 +40,7 @@ int32_t List::getLength() { return itemCount; } //-- getLength * is a private method, I feel that's a valid assumption **/ void txList::insertAfter(void* objPtr, ListItem* refItem) { - //-- if refItem == null insert at front - if (!refItem) { - insertBefore(objPtr, firstItem); - } else { - insertBefore(objPtr, refItem->nextItem); - } + insertBefore(objPtr, refItem ? refItem->nextItem : firstItem); } //-- insertAfter /** @@ -143,7 +138,7 @@ void txListIterator::addAfter(void* objPtr) { if (currentItem || !atEndOfList) { list->insertAfter(objPtr, currentItem); } else { - list->insertBefore(objPtr, 0); + list->insertBefore(objPtr, nullptr); } } //-- addAfter @@ -157,7 +152,7 @@ void txListIterator::addBefore(void* objPtr) { if (currentItem || atEndOfList) { list->insertBefore(objPtr, currentItem); } else { - list->insertAfter(objPtr, 0); + list->insertAfter(objPtr, nullptr); } } //-- addBefore