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
92170955
Commit
92170955
authored
Nov 02, 2011
by
antirez
Browse files
optimized object creation in multi-bulk protocol parsing
parent
b8d743e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
92170955
...
...
@@ -775,15 +775,32 @@ int processMultibulkBuffer(redisClient *c) {
/* Not enough data (+2 == trailing \r\n) */
break
;
}
else
{
c
->
argv
[
c
->
argc
++
]
=
createStringObject
(
c
->
querybuf
+
pos
,
c
->
bulklen
);
pos
+=
c
->
bulklen
+
2
;
/* Optimization: if the buffer contanins JUST our bulk element
* instead of creating a new object by *copying* the sds we
* just use the current sds string. */
if
(
pos
==
0
&&
sdslen
(
c
->
querybuf
)
>
4096
&&
(
signed
)
sdslen
(
c
->
querybuf
)
==
c
->
bulklen
+
2
)
{
c
->
argv
[
c
->
argc
++
]
=
createObject
(
REDIS_STRING
,
c
->
querybuf
);
sdsIncrLen
(
c
->
querybuf
,
-
2
);
/* remove CRLF */
c
->
querybuf
=
sdsempty
();
/* Assume that if we saw a fat argument we'll see another one
* likely... */
c
->
querybuf
=
sdsMakeRoomFor
(
c
->
querybuf
,
c
->
bulklen
+
2
);
pos
=
0
;
}
else
{
c
->
argv
[
c
->
argc
++
]
=
createStringObject
(
c
->
querybuf
+
pos
,
c
->
bulklen
);
pos
+=
c
->
bulklen
+
2
;
}
c
->
bulklen
=
-
1
;
c
->
multibulklen
--
;
}
}
/* Trim to pos */
c
->
querybuf
=
sdsrange
(
c
->
querybuf
,
pos
,
-
1
);
if
(
pos
)
c
->
querybuf
=
sdsrange
(
c
->
querybuf
,
pos
,
-
1
);
/* We're done when c->multibulk == 0 */
if
(
c
->
multibulklen
==
0
)
{
...
...
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