From b56cf9f9031898e372f85d4155be32c6e63802fd Mon Sep 17 00:00:00 2001 From: jsteemann Date: Sat, 25 Jun 2016 23:48:09 +0200 Subject: [PATCH] optimized away an unneeded shared_ptr --- arangod/Utils/OperationCursor.h | 6 +----- arangod/Utils/Transaction.cpp | 8 ++------ arangod/V8Server/v8-query.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/arangod/Utils/OperationCursor.h b/arangod/Utils/OperationCursor.h index 53f0d82be0..703c203746 100644 --- a/arangod/Utils/OperationCursor.h +++ b/arangod/Utils/OperationCursor.h @@ -44,7 +44,6 @@ struct OperationCursor { public: int code; - std::shared_ptr customTypeHandler; private: @@ -57,16 +56,13 @@ struct OperationCursor { public: explicit OperationCursor(int code) : code(code), - customTypeHandler(), _hasMore(false), _limit(0), _originalLimit(0), _batchSize(1000) {} - OperationCursor(std::shared_ptr handler, - IndexIterator* iterator, uint64_t limit, uint64_t batchSize) + OperationCursor(IndexIterator* iterator, uint64_t limit, uint64_t batchSize) : code(TRI_ERROR_NO_ERROR), - customTypeHandler(handler), _indexIterator(iterator), _hasMore(true), _limit(limit), // _limit is modified later on diff --git a/arangod/Utils/Transaction.cpp b/arangod/Utils/Transaction.cpp index 34fd1c3a0b..e3ae3c8a03 100644 --- a/arangod/Utils/Transaction.cpp +++ b/arangod/Utils/Transaction.cpp @@ -2868,9 +2868,7 @@ OperationCursor* Transaction::indexScanForCondition( return new OperationCursor(TRI_ERROR_OUT_OF_MEMORY); } - return new OperationCursor( - _transactionContextPtr->orderCustomTypeHandler(), iterator.release(), limit, - batchSize); + return new OperationCursor(iterator.release(), limit, batchSize); } ////////////////////////////////////////////////////////////////////////////// @@ -2960,9 +2958,7 @@ std::shared_ptr Transaction::indexScan( uint64_t unused = 0; iterator->skip(skip, unused); - return std::make_shared( - _transactionContextPtr->orderCustomTypeHandler(), iterator.release(), limit, - batchSize); + return std::make_shared(iterator.release(), limit, batchSize); } //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-query.cpp b/arangod/V8Server/v8-query.cpp index 80562d5047..7b370ff345 100644 --- a/arangod/V8Server/v8-query.cpp +++ b/arangod/V8Server/v8-query.cpp @@ -206,8 +206,8 @@ static void JS_AllQuery(v8::FunctionCallbackInfo const& args) { std::string collectionName(collection->_name); - SingleCollectionTransaction trx(V8TransactionContext::Create(collection->_vocbase, true), - collection->_cid, TRI_TRANSACTION_READ); + std::shared_ptr transactionContext = V8TransactionContext::Create(collection->_vocbase, true); + SingleCollectionTransaction trx(transactionContext, collection->_cid, TRI_TRANSACTION_READ); int res = trx.begin(); @@ -245,7 +245,7 @@ static void JS_AllQuery(v8::FunctionCallbackInfo const& args) { // copy default options VPackOptions resultOptions = VPackOptions::Defaults; - resultOptions.customTypeHandler = opCursor->customTypeHandler.get(); + resultOptions.customTypeHandler = transactionContext->orderCustomTypeHandler().get(); auto batch = std::make_shared(TRI_ERROR_NO_ERROR); opCursor->getMore(batch); @@ -289,8 +289,8 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo const& args) { std::string collectionName(col->_name); - SingleCollectionTransaction trx(V8TransactionContext::Create(col->_vocbase, true), - col->_cid, TRI_TRANSACTION_READ); + std::shared_ptr transactionContext = V8TransactionContext::Create(col->_vocbase, true); + SingleCollectionTransaction trx(transactionContext, col->_cid, TRI_TRANSACTION_READ); int res = trx.begin(); @@ -320,7 +320,7 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo const& args) { // copy default options VPackOptions resultOptions = VPackOptions::Defaults; - resultOptions.customTypeHandler = cursor.customTypeHandler.get(); + resultOptions.customTypeHandler = transactionContext->orderCustomTypeHandler().get(); TRI_V8_RETURN(TRI_VPackToV8(isolate, doc.at(0), &resultOptions)); TRI_V8_TRY_CATCH_END }