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
09a50d34
Commit
09a50d34
authored
Sep 14, 2016
by
antirez
Browse files
dict.c: dictReplaceRaw() -> dictAddOrFind().
What they say about "naming things" in programming?
parent
041ab044
Changes
3
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
09a50d34
...
@@ -943,7 +943,7 @@ void setExpire(redisDb *db, robj *key, long long when) {
...
@@ -943,7 +943,7 @@ void setExpire(redisDb *db, robj *key, long long when) {
/* Reuse the sds from the main dict in the expire dict */
/* Reuse the sds from the main dict in the expire dict */
kde
=
dictFind
(
db
->
dict
,
key
->
ptr
);
kde
=
dictFind
(
db
->
dict
,
key
->
ptr
);
serverAssertWithInfo
(
NULL
,
key
,
kde
!=
NULL
);
serverAssertWithInfo
(
NULL
,
key
,
kde
!=
NULL
);
de
=
dict
ReplaceRaw
(
db
->
expires
,
dictGetKey
(
kde
));
de
=
dict
AddOrFind
(
db
->
expires
,
dictGetKey
(
kde
));
dictSetSignedIntegerVal
(
de
,
when
);
dictSetSignedIntegerVal
(
de
,
when
);
}
}
...
...
src/dict.c
View file @
09a50d34
...
@@ -395,13 +395,13 @@ int dictReplace(dict *d, void *key, void *val)
...
@@ -395,13 +395,13 @@ int dictReplace(dict *d, void *key, void *val)
}
}
/* Add or Find:
/* Add or Find:
* dict
ReplaceRaw
() is simply a version of dictAddRaw() that always
* dict
AddOrFind
() is simply a version of dictAddRaw() that always
* returns the hash entry of the specified key, even if the key already
* returns the hash entry of the specified key, even if the key already
* exists and can't be added (in that case the entry of the already
* exists and can't be added (in that case the entry of the already
* existing key is returned.)
* existing key is returned.)
*
*
* See dictAddRaw() for more information. */
* See dictAddRaw() for more information. */
dictEntry
*
dict
ReplaceRaw
(
dict
*
d
,
void
*
key
)
{
dictEntry
*
dict
AddOrFind
(
dict
*
d
,
void
*
key
)
{
dictEntry
*
entry
,
*
existing
;
dictEntry
*
entry
,
*
existing
;
entry
=
dictAddRaw
(
d
,
key
,
&
existing
);
entry
=
dictAddRaw
(
d
,
key
,
&
existing
);
return
entry
?
entry
:
existing
;
return
entry
?
entry
:
existing
;
...
...
src/dict.h
View file @
09a50d34
...
@@ -151,8 +151,8 @@ dict *dictCreate(dictType *type, void *privDataPtr);
...
@@ -151,8 +151,8 @@ dict *dictCreate(dictType *type, void *privDataPtr);
int
dictExpand
(
dict
*
d
,
unsigned
long
size
);
int
dictExpand
(
dict
*
d
,
unsigned
long
size
);
int
dictAdd
(
dict
*
d
,
void
*
key
,
void
*
val
);
int
dictAdd
(
dict
*
d
,
void
*
key
,
void
*
val
);
dictEntry
*
dictAddRaw
(
dict
*
d
,
void
*
key
,
dictEntry
**
existing
);
dictEntry
*
dictAddRaw
(
dict
*
d
,
void
*
key
,
dictEntry
**
existing
);
dictEntry
*
dictAddOrFind
(
dict
*
d
,
void
*
key
);
int
dictReplace
(
dict
*
d
,
void
*
key
,
void
*
val
);
int
dictReplace
(
dict
*
d
,
void
*
key
,
void
*
val
);
dictEntry
*
dictReplaceRaw
(
dict
*
d
,
void
*
key
);
int
dictDelete
(
dict
*
d
,
const
void
*
key
);
int
dictDelete
(
dict
*
d
,
const
void
*
key
);
dictEntry
*
dictUnlink
(
dict
*
ht
,
const
void
*
key
);
dictEntry
*
dictUnlink
(
dict
*
ht
,
const
void
*
key
);
void
dictFreeUnlinkedEntry
(
dict
*
d
,
dictEntry
*
he
);
void
dictFreeUnlinkedEntry
(
dict
*
d
,
dictEntry
*
he
);
...
...
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