Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
f7740faf
Commit
f7740faf
authored
Jul 25, 2018
by
zhaozhao.zz
Committed by
antirez
Jul 30, 2018
Browse files
optimize flushdb, avoid useless loops
parent
0c008376
Changes
1
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
f7740faf
...
@@ -329,7 +329,7 @@ robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
...
@@ -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*)) {
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment