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
9454f7b3
Commit
9454f7b3
authored
Feb 25, 2015
by
Salvatore Sanfilippo
Browse files
Merge pull request #2050 from mattsta/bitops-no-overalloc
Bitops: Stop overallocating storage space on set
parents
e00cb78f
badf0f00
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bitops.c
View file @
9454f7b3
...
...
@@ -229,19 +229,17 @@ void setbitCommand(redisClient *c) {
return
;
}
byte
=
bitoffset
>>
3
;
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
if
(
o
==
NULL
)
{
o
=
createObject
(
REDIS_STRING
,
sds
empty
(
));
o
=
createObject
(
REDIS_STRING
,
sds
newlen
(
NULL
,
byte
+
1
));
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
o
);
}
else
{
if
(
checkType
(
c
,
o
,
REDIS_STRING
))
return
;
o
=
dbUnshareStringValue
(
c
->
db
,
c
->
argv
[
1
],
o
);
o
->
ptr
=
sdsgrowzero
(
o
->
ptr
,
byte
+
1
);
}
/* Grow sds value to the right length if necessary */
byte
=
bitoffset
>>
3
;
o
->
ptr
=
sdsgrowzero
(
o
->
ptr
,
byte
+
1
);
/* Get current values */
byteval
=
((
uint8_t
*
)
o
->
ptr
)[
byte
];
bit
=
7
-
(
bitoffset
&
0x7
);
...
...
src/t_string.c
View file @
9454f7b3
...
...
@@ -206,7 +206,7 @@ void setrangeCommand(redisClient *c) {
if
(
checkStringLength
(
c
,
offset
+
sdslen
(
value
))
!=
REDIS_OK
)
return
;
o
=
createObject
(
REDIS_STRING
,
sds
empty
(
));
o
=
createObject
(
REDIS_STRING
,
sds
newlen
(
NULL
,
offset
+
sdslen
(
value
)
));
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
o
);
}
else
{
size_t
olen
;
...
...
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