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
6ed8c282
Commit
6ed8c282
authored
Apr 25, 2016
by
Oran Agra
Browse files
dict.c minor optimization
parent
7b52ef1d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/dict.c
View file @
6ed8c282
...
...
@@ -424,7 +424,7 @@ static int dictGenericDelete(dict *d, const void *key, int nofree)
he
=
d
->
ht
[
table
].
table
[
idx
];
prevHe
=
NULL
;
while
(
he
)
{
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
{
if
(
key
==
he
->
key
||
dictCompareKeys
(
d
,
key
,
he
->
key
))
{
/* Unlink the element from the list */
if
(
prevHe
)
prevHe
->
next
=
he
->
next
;
...
...
@@ -494,14 +494,14 @@ dictEntry *dictFind(dict *d, const void *key)
dictEntry
*
he
;
unsigned
int
h
,
idx
,
table
;
if
(
d
->
ht
[
0
].
size
==
0
)
return
NULL
;
/*
We don't have a table at all
*/
if
(
d
->
ht
[
0
].
used
+
d
->
ht
[
1
].
used
==
0
)
return
NULL
;
/*
dict is empty
*/
if
(
dictIsRehashing
(
d
))
_dictRehashStep
(
d
);
h
=
dictHashKey
(
d
,
key
);
for
(
table
=
0
;
table
<=
1
;
table
++
)
{
idx
=
h
&
d
->
ht
[
table
].
sizemask
;
he
=
d
->
ht
[
table
].
table
[
idx
];
while
(
he
)
{
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
if
(
key
==
he
->
key
||
dictCompareKeys
(
d
,
key
,
he
->
key
))
return
he
;
he
=
he
->
next
;
}
...
...
@@ -981,7 +981,7 @@ static int _dictKeyIndex(dict *d, const void *key)
/* Search if this slot does not already contain the given key */
he
=
d
->
ht
[
table
].
table
[
idx
];
while
(
he
)
{
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
if
(
key
==
he
->
key
||
dictCompareKeys
(
d
,
key
,
he
->
key
))
return
-
1
;
he
=
he
->
next
;
}
...
...
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