Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
6a7841eb
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a7841eb
编写于
11月 02, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added an union in the dict.h structure to store 64 bit integers directly into hash table entries.
上级
ef23f3ac
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
7 deletion
+12
-7
src/dict.c
src/dict.c
+1
-2
src/dict.h
src/dict.h
+11
-5
未找到文件。
src/dict.c
浏览文件 @
6a7841eb
...
...
@@ -270,7 +270,7 @@ int dictAdd(dict *d, void *key, void *val)
if
((
index
=
_dictKeyIndex
(
d
,
key
))
==
-
1
)
return
DICT_ERR
;
/* Allocate
s the memory and stores ke
y */
/* Allocate
the memory and store the new entr
y */
ht
=
dictIsRehashing
(
d
)
?
&
d
->
ht
[
1
]
:
&
d
->
ht
[
0
];
entry
=
zmalloc
(
sizeof
(
*
entry
));
entry
->
next
=
ht
->
table
[
index
];
...
...
@@ -297,7 +297,6 @@ int dictReplace(dict *d, void *key, void *val)
return
1
;
/* It already exists, get the entry */
entry
=
dictFind
(
d
,
key
);
/* Free the old value and set the new one */
/* Set the new value and free the old one. Note that it is important
* to do that in this order, as the value may just be exactly the same
* as the previous one. In this context, think to reference counting,
...
...
src/dict.h
浏览文件 @
6a7841eb
...
...
@@ -33,6 +33,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#ifndef __DICT_H
#define __DICT_H
...
...
@@ -44,7 +46,11 @@
typedef
struct
dictEntry
{
void
*
key
;
void
*
val
;
union
{
void
*
val
;
uint64_t
u64
;
int64_t
i64
;
}
v
;
struct
dictEntry
*
next
;
}
dictEntry
;
...
...
@@ -90,13 +96,13 @@ typedef struct dictIterator {
/* ------------------------------- Macros ------------------------------------*/
#define dictFreeEntryVal(d, entry) \
if ((d)->type->valDestructor) \
(d)->type->valDestructor((d)->privdata, (entry)->val)
(d)->type->valDestructor((d)->privdata, (entry)->v
.v
al)
#define dictSetHashVal(d, entry, _val_) do { \
if ((d)->type->valDup) \
entry->val = (d)->type->valDup((d)->privdata, _val_); \
entry->v
.v
al = (d)->type->valDup((d)->privdata, _val_); \
else \
entry->val = (_val_); \
entry->v
.v
al = (_val_); \
} while(0)
#define dictFreeEntryKey(d, entry) \
...
...
@@ -118,7 +124,7 @@ typedef struct dictIterator {
#define dictHashKey(d, key) (d)->type->hashFunction(key)
#define dictGetEntryKey(he) ((he)->key)
#define dictGetEntryVal(he) ((he)->val)
#define dictGetEntryVal(he) ((he)->v
.v
al)
#define dictSlots(d) ((d)->ht[0].size+(d)->ht[1].size)
#define dictSize(d) ((d)->ht[0].used+(d)->ht[1].used)
#define dictIsRehashing(ht) ((ht)->rehashidx != -1)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录