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:
int code;
std::shared_ptr<VPackCustomTypeHandler> 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<VPackCustomTypeHandler> 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

View File

@ -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<OperationCursor> Transaction::indexScan(
uint64_t unused = 0;
iterator->skip(skip, unused);
return std::make_shared<OperationCursor>(
_transactionContextPtr->orderCustomTypeHandler(), iterator.release(), limit,
batchSize);
return std::make_shared<OperationCursor>(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);
SingleCollectionTransaction trx(V8TransactionContext::Create(collection->_vocbase, true),
collection->_cid, TRI_TRANSACTION_READ);
std::shared_ptr<V8TransactionContext> 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<v8::Value> const& args) {
// copy default options
VPackOptions resultOptions = VPackOptions::Defaults;
resultOptions.customTypeHandler = opCursor->customTypeHandler.get();
resultOptions.customTypeHandler = transactionContext->orderCustomTypeHandler().get();
auto batch = std::make_shared<OperationResult>(TRI_ERROR_NO_ERROR);
opCursor->getMore(batch);
@ -289,8 +289,8 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
std::string collectionName(col->_name);
SingleCollectionTransaction trx(V8TransactionContext::Create(col->_vocbase, true),
col->_cid, TRI_TRANSACTION_READ);
std::shared_ptr<V8TransactionContext> 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<v8::Value> 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
}