[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.
This commit is contained in:
Behdad Esfahbod 2009-03-11 13:56:09 -04:00
parent 916640ce40
commit 7d35c11b33
2 changed files with 10 additions and 2 deletions

View File

@ -313,6 +313,7 @@ typedef struct _FcStrBuf {
FcBool failed;
int len;
int size;
FcChar8 buf_static[16 * sizeof (void *)];
} FcStrBuf;
struct _FcCache {

View File

@ -709,12 +709,19 @@ FcUtf16Len (const FcChar8 *string,
void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size)
{
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