8000 micro-optimize RocksDBComparator by jsteemann · Pull Request #14758 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

micro-optimize RocksDBComparator #14758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicki 8000 ng “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions arangod/RocksDBEngine/RocksDBComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,25 @@ int compareIndexedValues(arangodb::velocypack::Slice const& lhs,

arangodb::velocypack::ArrayIterator lhsIter(lhs);
arangodb::velocypack::ArrayIterator rhsIter(rhs);
size_t const lLength = lhsIter.size();
size_t const rLength = rhsIter.size();

while (lhsIter.valid() || rhsIter.valid()) {
size_t i = lhsIter.index();
do {
bool lhsValid = lhsIter.valid();
bool rhsValid = rhsIter.valid();

if (!lhsValid && !rhsValid) {
return static_cast<int>(lhsIter.size() - rhsIter.size());
}

int res = arangodb::basics::VelocyPackHelper::compare(
(i < lLength ? *lhsIter : VPackSlice::noneSlice()),
(i < rLength ? *rhsIter : VPackSlice::noneSlice()), true);
(lhsValid ? *lhsIter : VPackSlice::noneSlice()),
(rhsValid ? *rhsIter : VPackSlice::noneSlice()), true);
if (res != 0) {
return res;
}

++lhsIter;
++rhsIter;
}

return static_cast<int>(lLength - rLength);
} while (true);
}

} // namespace
Expand Down
0