diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2009-03-11 13:56:09 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-03-12 13:14:37 -0400 |
commit | 7d35c11b3304659d8be43913c9b125f2b5b38516 (patch) | |
tree | 63bb94aa3a35f584aaa022cad670b974acfb0a26 /src | |
parent | 916640ce40b995d1d97244975139ec0c030483e4 (diff) |
[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.
Diffstat (limited to 'src')
-rw-r--r-- | src/fcint.h | 1 | ||||
-rw-r--r-- | src/fcstr.c | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/fcint.h b/src/fcint.h index b667e547..be520e78 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 3b84ac0d..4fbb1a21 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 |