Bug 1729329 - Mark PathExpr::addExpr as infallible. r=farre

Differential Revision: https://phabricator.services.mozilla.com/D124663
This commit is contained in:
Peter Van der Beken 2021-09-29 07:24:39 +00:00
Родитель cfb0fd3a44
Коммит 4a866d01ab
3 изменённых файлов: 4 добавлений и 14 удалений

Просмотреть файл

@ -700,9 +700,8 @@ class PathExpr : public Expr {
* The ownership of the given Expr is passed over the PathExpr,
* even on failure.
* @param aExpr the Expr to add to this PathExpr
* @return nsresult indicating out of memory
*/
nsresult addExpr(Expr* aExpr, PathOperator pathOp);
void addExpr(Expr* aExpr, PathOperator pathOp);
/**
* Removes and deletes the expression at the given index.

Просмотреть файл

@ -644,11 +644,7 @@ nsresult txExprParser::createPathExpr(txExprLexer& lexer,
// We have a PathExpr containing several steps
UniquePtr<PathExpr> pathExpr(new PathExpr());
rv = pathExpr->addExpr(expr.get(), PathExpr::RELATIVE_OP);
NS_ENSURE_SUCCESS(rv, rv);
Unused << expr.release();
pathExpr->addExpr(expr.release(), PathExpr::RELATIVE_OP);
// this is ugly
while (1) {
@ -669,10 +665,7 @@ nsresult txExprParser::createPathExpr(txExprLexer& lexer,
rv = createLocationStep(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
rv = pathExpr->addExpr(expr.get(), pathOp);
NS_ENSURE_SUCCESS(rv, rv);
Unused << expr.release();
pathExpr->addExpr(expr.release(), pathOp);
}
MOZ_ASSERT_UNREACHABLE("internal xpath parser error");
return NS_ERROR_UNEXPECTED;

Просмотреть файл

@ -21,14 +21,12 @@ using mozilla::WrapUnique;
* Adds the Expr to this PathExpr
* @param expr the Expr to add to this PathExpr
**/
nsresult PathExpr::addExpr(Expr* aExpr, PathOperator aPathOp) {
void PathExpr::addExpr(Expr* aExpr, PathOperator aPathOp) {
NS_ASSERTION(!mItems.IsEmpty() || aPathOp == RELATIVE_OP,
"First step has to be relative in PathExpr");
PathExprItem* pxi = mItems.AppendElement();
pxi->expr = WrapUnique(aExpr);
pxi->pathOp = aPathOp;
return NS_OK;
}
//-----------------------------/