[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:
parent
916640ce40
commit
7d35c11b33
|
@ -313,6 +313,7 @@ typedef struct _FcStrBuf {
|
|||
FcBool failed;
|
||||
int len;
|
||||
int size;
|
||||
FcChar8 buf_static[16 * sizeof (void *)];
|
||||
} FcStrBuf;
|
||||
|
||||
struct _FcCache {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue