sds copies uninitialized data wasting time for everyone

Former-commit-id: a1475af1e4ab97337287d4ef08d092ffabbb73ca
This commit is contained in:
John Sully 2019-03-02 19:27:52 -05:00
parent 15c301798f
commit c5a3c43d2a

View File

@ -227,7 +227,9 @@ sds sdsMakeRoomFor(sds s, size_t addlen) {
if (type == SDS_TYPE_5) type = SDS_TYPE_8;
hdrlen = sdsHdrSize(type);
if (oldtype==type) {
if (oldtype==type && (len+1024) >= avail) {
// note: if we have a lot of free space don't use this as we don't want s_realloc copying
// uninitialized data
newsh = s_realloc(sh, hdrlen+newlen+1, MALLOC_SHARED);
if (newsh == NULL) return NULL;
s = (char*)newsh+hdrlen;