MCPcopy Create free account
hub / github.com/ElementsProject/elements / Prev

Method Prev

src/leveldb/db/db_iter.cc:209–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void DBIter::Prev() {
210 assert(valid_);
211
212 if (direction_ == kForward) { // Switch directions?
213 // iter_ is pointing at the current entry. Scan backwards until
214 // the key changes so we can use the normal reverse scanning code.
215 assert(iter_->Valid()); // Otherwise valid_ would have been false
216 SaveKey(ExtractUserKey(iter_->key()), &saved_key_);
217 while (true) {
218 iter_->Prev();
219 if (!iter_->Valid()) {
220 valid_ = false;
221 saved_key_.clear();
222 ClearSavedValue();
223 return;
224 }
225 if (user_comparator_->Compare(ExtractUserKey(iter_->key()), saved_key_) <
226 0) {
227 break;
228 }
229 }
230 direction_ = kReverse;
231 }
232
233 FindPrevUserEntry();
234}
235
236void DBIter::FindPrevUserEntry() {
237 assert(direction_ == kReverse);

Callers 5

TESTFunction · 0.45
ReadReverseMethod · 0.45
FindPrevUserEntryMethod · 0.45
TESTFunction · 0.45
leveldb_iter_prevFunction · 0.45

Calls 5

ExtractUserKeyFunction · 0.85
ValidMethod · 0.45
keyMethod · 0.45
clearMethod · 0.45
CompareMethod · 0.45

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36