Bug 616774 followup: Remove nullchecks after new that are no longer needed. r=sicking
authorTimothy Zhu <nattofriends@gmail.com>
Mon, 07 Nov 2011 22:27:27 -0800
changeset 79933 81dedcc49ac027b7a5b118c4e73f7785712421a7
parent 79932 048ee4bf28f215ffd7cf6b180622193e971ca682
child 79934 504d3127b9a6b2fa6c4e3490213e167a33fffab4
push id21445
push usersicking@mozilla.com
push dateTue, 08 Nov 2011 06:29:57 +0000
treeherdermozilla-central@81dedcc49ac0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs616774
milestone10.0a1
first release with
nightly linux32
81dedcc49ac0 / 10.0a1 / 20111108031146 / files
nightly linux64
81dedcc49ac0 / 10.0a1 / 20111108031146 / files
nightly mac
81dedcc49ac0 / 10.0a1 / 20111108031146 / files
nightly win32
81dedcc49ac0 / 10.0a1 / 20111108031146 / files
nightly win64
81dedcc49ac0 / 10.0a1 / 20111108031146 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 616774 followup: Remove nullchecks after new that are no longer needed. r=sicking
content/xslt/src/xpath/txExprParser.cpp
--- a/content/xslt/src/xpath/txExprParser.cpp
+++ b/content/xslt/src/xpath/txExprParser.cpp
@@ -108,17 +108,16 @@ txExprParser::createAVT(const nsSubstrin
             }
 
             if (start == iter && literalString.IsEmpty()) {
                 // Restart the loop since we didn't create an expression
                 continue;
             }
             newExpr = new txLiteralExpr(literalString +
                                         Substring(start, iter));
-            NS_ENSURE_TRUE(newExpr, NS_ERROR_OUT_OF_MEMORY);
         }
         else {
             // Parse expressions, iter is already past the initial '{' when
             // we get here.
             while (iter != end) {
                 if (*iter == '}') {
                     rv = createExprInternal(Substring(start, iter),
                                             start - avtStart, aContext,
@@ -166,17 +165,16 @@ txExprParser::createAVT(const nsSubstrin
 
     if (inExpr) {
         aContext->SetErrorOffset(iter - avtStart);
         return NS_ERROR_XPATH_UNBALANCED_CURLY_BRACE;
     }
 
     if (!expr) {
         expr = new txLiteralExpr(EmptyString());
-        NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
     }
 
     *aResult = expr.forget();
 
     return NS_OK;
 }
 
 nsresult
@@ -400,46 +398,42 @@ txExprParser::createFilterOrStep(txExprL
             {
                 nsCOMPtr<nsIAtom> prefix, lName;
                 PRInt32 nspace;
                 nsresult rv = resolveQName(tok->Value(), getter_AddRefs(prefix),
                                            aContext, getter_AddRefs(lName),
                                            nspace);
                 NS_ENSURE_SUCCESS(rv, rv);
                 expr = new VariableRefExpr(prefix, lName, nspace);
-                NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
             }
             break;
         case Token::L_PAREN:
             rv = createExpr(lexer, aContext, getter_Transfers(expr));
             NS_ENSURE_SUCCESS(rv, rv);
 
             if (lexer.nextToken()->mType != Token::R_PAREN) {
                 lexer.pushBack();
                 return NS_ERROR_XPATH_PAREN_EXPECTED;
             }
             break;
         case Token::LITERAL :
             expr = new txLiteralExpr(tok->Value());
-            NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
             break;
         case Token::NUMBER:
         {
             expr = new txLiteralExpr(Double::toDouble(tok->Value()));
-            NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
             break;
         }
         default:
             lexer.pushBack();
             return createLocationStep(lexer, aContext, aResult);
     }
 
     if (lexer.peek()->mType == Token::L_BRACKET) {
         nsAutoPtr<FilterExpr> filterExpr(new FilterExpr(expr));
-        NS_ENSURE_TRUE(filterExpr, NS_ERROR_OUT_OF_MEMORY);
 
         expr.forget();
 
         //-- handle predicates
         rv = parsePredicates(filterExpr, lexer, aContext);
         NS_ENSURE_SUCCESS(rv, rv);
         expr = filterExpr.forget();
     }
@@ -467,33 +461,31 @@ txExprParser::createFunctionCall(txExprL
                                getter_AddRefs(lName), namespaceID);
     NS_ENSURE_SUCCESS(rv, rv);
 
     txCoreFunctionCall::eType type;
     if (namespaceID == kNameSpaceID_None &&
         txCoreFunctionCall::getTypeFromAtom(lName, type)) {
         // It is a known built-in function.
         fnCall = new txCoreFunctionCall(type);
-        NS_ENSURE_TRUE(fnCall, NS_ERROR_OUT_OF_MEMORY);
     }
 
     // check extension functions and xslt
     if (!fnCall) {
         rv = aContext->resolveFunctionCall(lName, namespaceID,
                                            getter_Transfers(fnCall));
 
         if (rv == NS_ERROR_NOT_IMPLEMENTED) {
             // this should just happen for unparsed-entity-uri()
             NS_ASSERTION(!fnCall, "Now is it implemented or not?");
             rv = parseParameters(0, lexer, aContext);
             NS_ENSURE_SUCCESS(rv, rv);
 
             *aResult = new txLiteralExpr(tok->Value() +
                                          NS_LITERAL_STRING(" not implemented."));
-            NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
             return NS_OK;
         }
 
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     //-- handle parametes
@@ -571,24 +563,22 @@ txExprParser::createLocationStep(txExprL
             lexer.nextToken();
             axisIdentifier = LocationStep::ATTRIBUTE_AXIS;
             break;
         case Token::PARENT_NODE :
             //-- eat token
             lexer.nextToken();
             axisIdentifier = LocationStep::PARENT_AXIS;
             nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
-            NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
             break;
         case Token::SELF_NODE :
             //-- eat token
             lexer.nextToken();
             axisIdentifier = LocationStep::SELF_AXIS;
             nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
-            NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
             break;
         default:
             break;
     }
 
     //-- get NodeTest unless an AbbreviatedStep was found
     nsresult rv = NS_OK;
     if (!nodeTest) {
@@ -603,27 +593,25 @@ txExprParser::createLocationStep(txExprL
                               nspace, true);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nodeTest =
               new txNameTest(prefix, lName, nspace,
                              axisIdentifier == LocationStep::ATTRIBUTE_AXIS ?
                              static_cast<PRUint16>(txXPathNodeType::ATTRIBUTE_NODE) :
                              static_cast<PRUint16>(txXPathNodeType::ELEMENT_NODE));
-            NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
         }
         else {
             lexer.pushBack();
             rv = createNodeTypeTest(lexer, getter_Transfers(nodeTest));
             NS_ENSURE_SUCCESS(rv, rv);
         }
     }
     
     nsAutoPtr<LocationStep> lstep(new LocationStep(nodeTest, axisIdentifier));
-    NS_ENSURE_TRUE(lstep, NS_ERROR_OUT_OF_MEMORY);
 
     nodeTest.forget();
 
     //-- handle predicates
     rv = parsePredicates(lstep, lexer, aContext);
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aExpr = lstep.forget();
@@ -689,17 +677,16 @@ txExprParser::createPathExpr(txExprLexer
 
     Token* tok = lexer.peek();
 
     // is this a root expression?
     if (tok->mType == Token::PARENT_OP) {
         lexer.nextToken();
         if (!isLocationStepToken(lexer.peek())) {
             *aResult = new RootExpr();
-            NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
             return NS_OK;
         }
         lexer.pushBack();
     }
 
     // parse first step (possibly a FilterExpr)
     nsresult rv = NS_OK;
     if (tok->mType != Token::PARENT_OP &&
@@ -712,26 +699,24 @@ txExprParser::createPathExpr(txExprLexer
         if (tok->mType != Token::PARENT_OP &&
             tok->mType != Token::ANCESTOR_OP) {
             *aResult = expr.forget();
             return NS_OK;
         }
     }
     else {
         expr = new RootExpr();
-        NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
 
 #ifdef TX_TO_STRING
         static_cast<RootExpr*>(expr.get())->setSerialize(false);
 #endif
     }
     
     // We have a PathExpr containing several steps
     nsAutoPtr<PathExpr> pathExpr(new PathExpr());
-    NS_ENSURE_TRUE(pathExpr, NS_ERROR_OUT_OF_MEMORY);
 
     rv = pathExpr->addExpr(expr, PathExpr::RELATIVE_OP);
     NS_ENSURE_SUCCESS(rv, rv);
 
     expr.forget();
 
     // this is ugly
     while (1) {
@@ -777,17 +762,16 @@ txExprParser::createUnionExpr(txExprLexe
     NS_ENSURE_SUCCESS(rv, rv);
     
     if (lexer.peek()->mType != Token::UNION_OP) {
         *aResult = expr.forget();
         return NS_OK;
     }
 
     nsAutoPtr<UnionExpr> unionExpr(new UnionExpr());
-    NS_ENSURE_TRUE(unionExpr, NS_ERROR_OUT_OF_MEMORY);
 
     rv = unionExpr->addExpr(expr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     expr.forget();
 
     while (lexer.peek()->mType == Token::UNION_OP) {
         lexer.nextToken(); //-- eat token