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
hiredis
Commits
f6a50100
Commit
f6a50100
authored
Jan 19, 2011
by
Pieter Noordhuis
Browse files
Discard consumed part of buffer less often
parent
5962a2de
Changes
1
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
f6a50100
...
...
@@ -538,15 +538,10 @@ int redisReplyReaderGetReply(void *reader, void **reply) {
if
(
processItem
(
r
)
<
0
)
break
;
/* Discard the consumed part of the buffer. */
if
(
r
->
pos
>
0
)
{
if
(
r
->
pos
==
r
->
len
)
{
/* sdsrange has a quirck on this edge case. */
sdsfree
(
r
->
buf
);
r
->
buf
=
sdsempty
();
}
else
{
r
->
buf
=
sdsrange
(
r
->
buf
,
r
->
pos
,
r
->
len
);
}
/* Discard part of the buffer when we've consumed at least 1k, to avoid
* doing unnecessary calls to memmove() in sds.c. */
if
(
r
->
pos
>=
1024
)
{
r
->
buf
=
sdsrange
(
r
->
buf
,
r
->
pos
,
r
->
len
);
r
->
pos
=
0
;
r
->
len
=
sdslen
(
r
->
buf
);
}
...
...
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