1
0
Fork 0

optimized away an unneeded shared_ptr

This commit is contained in:
jsteemann 2016-06-25 23:48:09 +02:00
parent e340b2d710
commit b56cf9f903
3 changed files with 9 additions and 17 deletions

View File

@ -44,7 +44,6 @@ struct OperationCursor {
public: public:
int code; int code;
std::shared_ptr<VPackCustomTypeHandler> customTypeHandler;
private: private:
@ -57,16 +56,13 @@ struct OperationCursor {
public: public:
explicit OperationCursor(int code) explicit OperationCursor(int code)
: code(code), : code(code),
customTypeHandler(),
_hasMore(false), _hasMore(false),
_limit(0), _limit(0),
_originalLimit(0), _originalLimit(0),
_batchSize(1000) {} _batchSize(1000) {}
OperationCursor(std::shared_ptr<VPackCustomTypeHandler> handler, OperationCursor(IndexIterator* iterator, uint64_t limit, uint64_t batchSize)
IndexIterator* iterator, uint64_t limit, uint64_t batchSize)
: code(TRI_ERROR_NO_ERROR), : code(TRI_ERROR_NO_ERROR),
customTypeHandler(handler),
_indexIterator(iterator), _indexIterator(iterator),
_hasMore(true), _hasMore(true),
_limit(limit), // _limit is modified later on _limit(limit), // _limit is modified later on

View File

@ -2868,9 +2868,7 @@ OperationCursor* Transaction::indexScanForCondition(
return new OperationCursor(TRI_ERROR_OUT_OF_MEMORY); return new OperationCursor(TRI_ERROR_OUT_OF_MEMORY);
} }
return new OperationCursor( return new OperationCursor(iterator.release(), limit, batchSize);
_transactionContextPtr->orderCustomTypeHandler(), iterator.release(), limit,
batchSize);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -2960,9 +2958,7 @@ std::shared_ptr<OperationCursor> Transaction::indexScan(
uint64_t unused = 0; uint64_t unused = 0;
iterator->skip(skip, unused); iterator->skip(skip, unused);
return std::make_shared<OperationCursor>( return std::make_shared<OperationCursor>(iterator.release(), limit, batchSize);
_transactionContextPtr->orderCustomTypeHandler(), iterator.release(), limit,
batchSize);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -206,8 +206,8 @@ static void JS_AllQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
std::string collectionName(collection->_name); std::string collectionName(collection->_name);
SingleCollectionTransaction trx(V8TransactionContext::Create(collection->_vocbase, true), std::shared_ptr<V8TransactionContext> transactionContext = V8TransactionContext::Create(collection->_vocbase, true);
collection->_cid, TRI_TRANSACTION_READ); SingleCollectionTransaction trx(transactionContext, collection->_cid, TRI_TRANSACTION_READ);
int res = trx.begin(); int res = trx.begin();
@ -245,7 +245,7 @@ static void JS_AllQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
// copy default options // copy default options
VPackOptions resultOptions = VPackOptions::Defaults; VPackOptions resultOptions = VPackOptions::Defaults;
resultOptions.customTypeHandler = opCursor->customTypeHandler.get(); resultOptions.customTypeHandler = transactionContext->orderCustomTypeHandler().get();
auto batch = std::make_shared<OperationResult>(TRI_ERROR_NO_ERROR); auto batch = std::make_shared<OperationResult>(TRI_ERROR_NO_ERROR);
opCursor->getMore(batch); opCursor->getMore(batch);
@ -289,8 +289,8 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
std::string collectionName(col->_name); std::string collectionName(col->_name);
SingleCollectionTransaction trx(V8TransactionContext::Create(col->_vocbase, true), std::shared_ptr<V8TransactionContext> transactionContext = V8TransactionContext::Create(col->_vocbase, true);
col->_cid, TRI_TRANSACTION_READ); SingleCollectionTransaction trx(transactionContext, col->_cid, TRI_TRANSACTION_READ);
int res = trx.begin(); int res = trx.begin();
@ -320,7 +320,7 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
// copy default options // copy default options
VPackOptions resultOptions = VPackOptions::Defaults; 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_RETURN(TRI_VPackToV8(isolate, doc.at(0), &resultOptions));
TRI_V8_TRY_CATCH_END TRI_V8_TRY_CATCH_END
} }