[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 {
|
||||
|
|
11
src/fcstr.c
11
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
|
||||
|
|
Loading…
Reference in New Issue