1
0
Fork 0

Used a shared builder for a closure instead of creating a new one every time.

This commit is contained in:
Michael Hackstein 2016-04-26 10:50:30 +02:00
parent 0dc0dc2df7
commit 4d440220a5
1 changed files with 7 additions and 6 deletions

View File

@ -592,7 +592,8 @@ std::unique_ptr<ArangoDBPathFinder::Path> TRI_RunShortestPathSearch(
auto edgeFilterClosure = [&opts](VPackSlice edge)
-> bool { return opts.matchesEdge(edge); };
auto vertexFilterClosure = [&opts](VPackSlice const& vertex) -> bool {
VPackBuilder tmpBuilder;
auto vertexFilterClosure = [&opts, &tmpBuilder](VPackSlice const& vertex) -> bool {
std::string v = vertex.copyString();
size_t pos = v.find('/');
@ -607,12 +608,12 @@ std::unique_ptr<ArangoDBPathFinder::Path> TRI_RunShortestPathSearch(
std::string col = v.substr(0, pos);
std::string key = v.substr(pos + 1);
VPackBuilder tmp;
tmp.openObject();
tmp.add(Transaction::KeyString, VPackValue(key));
tmp.close();
tmpBuilder.clear();
tmpBuilder.openObject();
tmpBuilder.add(Transaction::KeyString, VPackValue(key));
tmpBuilder.close();
OperationOptions opOpts;
OperationResult opRes = opts.trx()->document(col, tmp.slice(), opOpts);
OperationResult opRes = opts.trx()->document(col, tmpBuilder.slice(), opOpts);
if (opRes.failed()) {
return false;
}