Skip to content

Commit

Permalink
code review, remove dbIteratorInitNextSafeIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Nov 14, 2023
1 parent ad4ec4f commit 736d9c1
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,19 @@ int dbIteratorGetCurrentSlot(dbIterator *dbit) {
return dbit->slot;
}

/* Used in dbIteratorNext, when getting the next entry in multi slot db, get
* the iterator of the next safe dictionary. */
void dbIteratorInitNextSafeIterator(dbIterator *dbit, dict *d) {
if (dbit->di.d) {
/* Before we move to the next dict, reset the iter of the previous dict. */
dictIterator *iter = &dbit->di;
dictResetIterator(iter);
}

dictInitSafeIterator(&dbit->di, d);
}

/* Returns next entry from the multi slot db. */
dictEntry *dbIteratorNext(dbIterator *dbit) {
dictEntry *de = dbit->di.d ? dictNext(&dbit->di) : NULL;
if (!de) { /* No current dict or reached the end of the dictionary. */
dict *d = dbIteratorNextDict(dbit);
if (!d) return NULL;
dbIteratorInitNextSafeIterator(dbit, d);

if (dbit->di.d) {
/* Before we move to the next dict, reset the iter of the previous dict. */
dictIterator *iter = &dbit->di;
dictResetIterator(iter);
}
dictInitSafeIterator(&dbit->di, d);
de = dictNext(&dbit->di);
}
return de;
Expand Down

0 comments on commit 736d9c1

Please sign in to comment.