mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
SDS: make sdscatfmt() faster by pre-allocating a bit.
This commit is contained in:
parent
40acb4412d
commit
f49f0a6f72
@ -603,6 +603,10 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
|
||||
long i;
|
||||
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);
|
||||
f = fmt; /* Next format specifier byte to process. */
|
||||
i = initlen; /* Position of the next byte to write to dest str. */
|
||||
|
Loading…
Reference in New Issue
Block a user