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
f49f0a6f
Commit
f49f0a6f
authored
Oct 02, 2019
by
antirez
Browse files
SDS: make sdscatfmt() faster by pre-allocating a bit.
parent
40acb441
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
f49f0a6f
...
@@ -603,6 +603,10 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
...
@@ -603,6 +603,10 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
long
i
;
long
i
;
va_list
ap
;
va_list
ap
;
/* To avoid continuous reallocations, let's start with a buffer that
* can hold at least two times the format string itself. It's not the
* best heuristic but seems to work in practice. */
s
=
sdsMakeRoomFor
(
s
,
initlen
+
strlen
(
fmt
)
*
2
);
va_start
(
ap
,
fmt
);
va_start
(
ap
,
fmt
);
f
=
fmt
;
/* Next format specifier byte to process. */
f
=
fmt
;
/* Next format specifier byte to process. */
i
=
initlen
;
/* Position of the next byte to write to dest str. */
i
=
initlen
;
/* Position of the next byte to write to dest str. */
...
...
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