Don't do O(N^2) operations in debug mode for vector memtable

Summary: As title. For every operation we're asserting Valid(), which sorts the data. That's pretty terrible. We have to be careful to have decent performance even with DEBUG builds.

Test Plan: make check

Reviewers: sdong, rven, yhchiang, MarkCallaghan

Reviewed By: MarkCallaghan

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D36969
This commit is contained in:
Igor Canadi 2015-04-13 16:11:47 -07:00
parent 08be1803ee
commit d41a565a4a

View File

@ -178,14 +178,12 @@ bool VectorRep::Iterator::Valid() const {
// Returns the key at the current position.
// REQUIRES: Valid()
const char* VectorRep::Iterator::key() const {
assert(Valid());
return *cit_;
}
// Advances to the next position.
// REQUIRES: Valid()
void VectorRep::Iterator::Next() {
assert(Valid());
if (cit_ == bucket_->end()) {
return;
}
@ -195,7 +193,6 @@ void VectorRep::Iterator::Next() {
// Advances to the previous position.
// REQUIRES: Valid()
void VectorRep::Iterator::Prev() {
assert(Valid());
if (cit_ == bucket_->begin()) {
// If you try to go back from the first element, the iterator should be
// invalidated. So we set it to past-the-end. This means that you can