From: Behdad Esfahbod Date: Wed, 11 Mar 2009 17:56:09 +0000 (-0400) Subject: [fcstr.c] Embed a static 64-byte buffer in FcStrBuf X-Git-Tag: 2.7.0~33 X-Git-Url: https://git.wh0rd.org/?p=fontconfig.git;a=commitdiff_plain;h=7d35c11b3304659d8be43913c9b125f2b5b38516 [fcstr.c] Embed a static 64-byte buffer in FcStrBuf Reduces number of mallocs called from FcStrBufChar in my small test from 900 down to 6. --- diff --git a/src/fcint.h b/src/fcint.h index b667e54..be520e7 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -313,6 +313,7 @@ typedef struct _FcStrBuf { FcBool failed; int len; int size; + FcChar8 buf_static[16 * sizeof (void *)]; } FcStrBuf; struct _FcCache { diff --git a/src/fcstr.c b/src/fcstr.c index 3b84ac0..4fbb1a2 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -710,11 +710,18 @@ FcUtf16Len (const FcChar8 *string, void FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size) { - buf->buf = init; + if (init) + { + buf->buf = init; + buf->size = size; + } else + { + buf->buf = buf->static_buf; + buf->size = sizeof (buf->static_buf); + } buf->allocated = FcFalse; buf->failed = FcFalse; buf->len = 0; - buf->size = size; } void