Bug 1029104 - Convert XPathExpression to WebIDL bindings, remove txResultRecycler::init. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 05 Jun 2014 15:14:56 +0200
changeset 213202 1d99047f17a5b138598b0aadaa3c1c313c4fb194
parent 213201 a6647b6784f277aab18b1a89774066f6c43e4ba1
child 213203 20fb9c5eefe1fbfe82b6933d280d660e7e1a866b
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1029104
milestone33.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 1029104 - Convert XPathExpression to WebIDL bindings, remove txResultRecycler::init. r=bz.
dom/xslt/xpath/XPathEvaluator.cpp
dom/xslt/xpath/txResultRecycler.cpp
dom/xslt/xpath/txResultRecycler.h
dom/xslt/xpath/txXPathOptimizer.cpp
dom/xslt/xslt/txExecutionState.cpp
dom/xslt/xslt/txMozillaXSLTProcessor.cpp
--- a/dom/xslt/xpath/XPathEvaluator.cpp
+++ b/dom/xslt/xpath/XPathEvaluator.cpp
@@ -105,23 +105,17 @@ XPathEvaluator::Evaluate(const nsAString
 
 NS_IMETHODIMP
 XPathEvaluator::CreateExpression(const nsAString & aExpression,
                                  nsIDOMXPathNSResolver *aResolver,
                                  nsIDOMXPathExpression **aResult)
 {
     nsresult rv;
     if (!mRecycler) {
-        nsRefPtr<txResultRecycler> recycler = new txResultRecycler;
-        NS_ENSURE_TRUE(recycler, NS_ERROR_OUT_OF_MEMORY);
-        
-        rv = recycler->init();
-        NS_ENSURE_SUCCESS(rv, rv);
-        
-        mRecycler = recycler;
+        mRecycler = new txResultRecycler;
     }
 
     nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
     XPathEvaluatorParseContext pContext(aResolver, !(doc && doc->IsHTML()));
 
     nsAutoPtr<Expr> expression;
     rv = txExprParser::createExpr(PromiseFlatString(aExpression), &pContext,
                                   getter_Transfers(expression));
--- a/dom/xslt/xpath/txResultRecycler.cpp
+++ b/dom/xslt/xpath/txResultRecycler.cpp
@@ -3,19 +3,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "txResultRecycler.h"
 #include "txExprResult.h"
 #include "txNodeSet.h"
 
 txResultRecycler::txResultRecycler()
-    : mEmptyStringResult(nullptr),
-      mTrueResult(nullptr),
-      mFalseResult(nullptr)
+    : mEmptyStringResult(new StringResult(nullptr)),
+      mTrueResult(new BooleanResult(true)),
+      mFalseResult(new BooleanResult(false))
 {
 }
 
 txResultRecycler::~txResultRecycler()
 {
     txStackIterator stringIter(&mStringResults);
     while (stringIter.hasNext()) {
         delete static_cast<StringResult*>(stringIter.next());
@@ -23,44 +23,16 @@ txResultRecycler::~txResultRecycler()
     txStackIterator nodesetIter(&mNodeSetResults);
     while (nodesetIter.hasNext()) {
         delete static_cast<txNodeSet*>(nodesetIter.next());
     }
     txStackIterator numberIter(&mNumberResults);
     while (numberIter.hasNext()) {
         delete static_cast<NumberResult*>(numberIter.next());
     }
-
-    NS_IF_RELEASE(mEmptyStringResult);
-    NS_IF_RELEASE(mTrueResult);
-    NS_IF_RELEASE(mFalseResult);
-}
-
-
-nsresult
-txResultRecycler::init()
-{
-    NS_ASSERTION(!mEmptyStringResult && !mTrueResult && !mFalseResult,
-                 "Already inited");
-    mEmptyStringResult = new StringResult(nullptr);
-    NS_ENSURE_TRUE(mEmptyStringResult, NS_ERROR_OUT_OF_MEMORY);
-
-    NS_ADDREF(mEmptyStringResult);
-
-    mTrueResult = new BooleanResult(true);
-    NS_ENSURE_TRUE(mTrueResult, NS_ERROR_OUT_OF_MEMORY);
-
-    NS_ADDREF(mTrueResult);
-
-    mFalseResult = new BooleanResult(false);
-    NS_ENSURE_TRUE(mFalseResult, NS_ERROR_OUT_OF_MEMORY);
-
-    NS_ADDREF(mFalseResult);
-
-    return NS_OK;
 }
 
 
 void
 txResultRecycler::recycle(txAExprResult* aResult)
 {
     NS_ASSERTION(aResult->mRefCnt == 0, "In-use txAExprResult recycled");
     nsRefPtr<txResultRecycler> kungFuDeathGrip;
--- a/dom/xslt/xpath/txResultRecycler.h
+++ b/dom/xslt/xpath/txResultRecycler.h
@@ -16,17 +16,16 @@ class txXPathNode;
 class NumberResult;
 class BooleanResult;
 
 class txResultRecycler
 {
 public:
     txResultRecycler();
     ~txResultRecycler();
-    nsresult init();
 
     void AddRef()
     {
         ++mRefCnt;
         NS_LOG_ADDREF(this, mRefCnt, "txResultRecycler", sizeof(*this));
     }
     void Release()
     {
@@ -67,14 +66,14 @@ public:
      */
     nsresult getNonSharedNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult);
 
 private:
     nsAutoRefCnt mRefCnt;
     txStack mStringResults;
     txStack mNodeSetResults;
     txStack mNumberResults;
-    StringResult* mEmptyStringResult;
-    BooleanResult* mTrueResult;
-    BooleanResult* mFalseResult;
+    nsRefPtr<StringResult> mEmptyStringResult;
+    nsRefPtr<BooleanResult> mTrueResult;
+    nsRefPtr<BooleanResult> mFalseResult;
 };
 
 #endif //txResultRecycler_h__
--- a/dom/xslt/xpath/txXPathOptimizer.cpp
+++ b/dom/xslt/xpath/txXPathOptimizer.cpp
@@ -75,21 +75,16 @@ txXPathOptimizer::optimize(Expr* aInExpr
     nsresult rv = NS_OK;
 
     // First check if the expression will produce the same result
     // under any context.
     Expr::ExprType exprType = aInExpr->getType();
     if (exprType != Expr::LITERAL_EXPR &&
         !aInExpr->isSensitiveTo(Expr::ANY_CONTEXT)) {
         nsRefPtr<txResultRecycler> recycler = new txResultRecycler;
-        NS_ENSURE_TRUE(recycler, NS_ERROR_OUT_OF_MEMORY);
-
-        rv = recycler->init();
-        NS_ENSURE_SUCCESS(rv, rv);
-
         txEarlyEvalContext context(recycler);
         nsRefPtr<txAExprResult> exprRes;
 
         // Don't throw if this fails since it could be that the expression
         // is or contains an error-expression.
         rv = aInExpr->evaluate(&context, getter_AddRefs(exprRes));
         if (NS_SUCCEEDED(rv)) {
             *aOutExpr = new txLiteralExpr(exprRes);
--- a/dom/xslt/xslt/txExecutionState.cpp
+++ b/dom/xslt/xslt/txExecutionState.cpp
@@ -120,20 +120,16 @@ txExecutionState::init(const txXPathNode
     // Set up loaded-documents-hash
     mLoadedDocuments.init(txXPathNodeUtils::getOwnerDocument(aNode));
 
     // Init members
     rv = mKeyHash.init();
     NS_ENSURE_SUCCESS(rv, rv);
     
     mRecycler = new txResultRecycler;
-    NS_ENSURE_TRUE(mRecycler, NS_ERROR_OUT_OF_MEMORY);
-    
-    rv = mRecycler->init();
-    NS_ENSURE_SUCCESS(rv, rv);
     
     // The actual value here doesn't really matter since noone should use this
     // value. But lets put something errorlike in just in case
     mGlobalVarPlaceholderValue = new StringResult(NS_LITERAL_STRING("Error"), nullptr);
     NS_ENSURE_TRUE(mGlobalVarPlaceholderValue, NS_ERROR_OUT_OF_MEMORY);
 
     // Initiate first instruction. This has to be done last since findTemplate
     // might use us.
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -465,20 +465,16 @@ txMozillaXSLTProcessor::AddXSLTParam(con
 
         // Set up context
         nsAutoPtr<txXPathNode> contextNode(
           txXPathNativeNode::createXPathNode(aContext));
         NS_ENSURE_TRUE(contextNode, NS_ERROR_OUT_OF_MEMORY);
 
         if (!mRecycler) {
             mRecycler = new txResultRecycler;
-            NS_ENSURE_TRUE(mRecycler, NS_ERROR_OUT_OF_MEMORY);
-
-            rv = mRecycler->init();
-            NS_ENSURE_SUCCESS(rv, rv);
         }
 
         txXSLTParamContext paramContext(&mParamNamespaceMap, *contextNode,
                                         mRecycler);
 
         // Parse
         nsAutoPtr<Expr> expr;
         rv = txExprParser::createExpr(aSelect, &paramContext,