mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
optimize flushdb, avoid useless loops
This commit is contained in:
parent
73cbc33a0a
commit
dd071ff6c9
7
src/db.c
7
src/db.c
@ -329,7 +329,7 @@ robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
|
|||||||
* database(s). Otherwise -1 is returned in the specific case the
|
* database(s). Otherwise -1 is returned in the specific case the
|
||||||
* DB number is out of range, and errno is set to EINVAL. */
|
* DB number is out of range, and errno is set to EINVAL. */
|
||||||
long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
||||||
int j, async = (flags & EMPTYDB_ASYNC);
|
int async = (flags & EMPTYDB_ASYNC);
|
||||||
long long removed = 0;
|
long long removed = 0;
|
||||||
|
|
||||||
if (dbnum < -1 || dbnum >= server.dbnum) {
|
if (dbnum < -1 || dbnum >= server.dbnum) {
|
||||||
@ -337,7 +337,10 @@ long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < server.dbnum; j++) {
|
int j = dbnum == -1 ? 0 : dbnum;
|
||||||
|
int dbmax = dbnum == -1 ? server.dbnum : dbnum+1;
|
||||||
|
|
||||||
|
for (; j < dbmax; j++) {
|
||||||
if (dbnum != -1 && dbnum != j) continue;
|
if (dbnum != -1 && dbnum != j) continue;
|
||||||
removed += dictSize(server.db[j].dict);
|
removed += dictSize(server.db[j].dict);
|
||||||
if (async) {
|
if (async) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user