From 8ad21e6b59e5e5a3104660f17ad2b0e9122edecf Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 15 Feb 2017 15:14:12 +0100 Subject: xplist: Improve writing of large PLIST_DATA nodes by growing buffer in advance Instead of letting the buffer grow by just the amount of bytes currently transformed to base64 - which is basically line by line - we now calculate the size of the output blob in advance and grow the buffer accordingly. This will reduce the amount of reallocs to just one, which is especially important for large data blobs. While this is a general improvement for all platforms, it is on platforms like Windows where realloc() can be REALLY slow; converting a 20mb blob to XML can easily take up to a minute (due to the several hundred thousand calls to realloc()). With this commit, it will be fast again. --- src/strbuf.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/strbuf.h') diff --git a/src/strbuf.h b/src/strbuf.h index 6b7f9d3..ba2c909 100644 --- a/src/strbuf.h +++ b/src/strbuf.h @@ -28,6 +28,7 @@ typedef struct bytearray_t strbuf_t; #define str_buf_new() byte_array_new() #define str_buf_free(__ba) byte_array_free(__ba) +#define str_buf_grow(__ba, __am) byte_array_grow(__ba, __am) #define str_buf_append(__ba, __str, __len) byte_array_append(__ba, (void*)(__str), __len) #endif -- cgit v1.1-32-gdbae