From: Patrick Lam Date: Tue, 7 Feb 2006 02:33:57 +0000 (+0000) Subject: Remove de-escaping logic because FcCacheWriteString doesn't escape anyway. X-Git-Tag: fc-2_3_94~33 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=799157dbbf55d1bf13b1e63faf3b530979116aca;p=fontconfig.git Remove de-escaping logic because FcCacheWriteString doesn't escape anyway. Do blockwise reading instead of byte-wise for performance. --- diff --git a/ChangeLog b/ChangeLog index 8378d5d..098f167 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-02-07 Dirk Mueller + + * src/fccache.c (FcCacheReadString, FcCacheSkipString): + + Remove de-escaping logic because FcCacheWriteString + doesn't escape anyway. Do blockwise reading instead + of byte-wise for performance. + 2006-02-06 Patrick Lam Takashi Iwai diff --git a/src/fccache.c b/src/fccache.c index f2a41d4..dd03322 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -82,68 +82,44 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16]); static char * FcCacheReadString (int fd, char *dest, int len) { - FcChar8 c; - FcBool escape; - int size; - int i; + int size; + int slen; if (len == 0) return 0; - - size = len; - i = 0; - escape = FcFalse; - while (read (fd, &c, 1) == 1) + + size = read (fd, dest, len-1); + + if (size > 0) { - if (!escape) - { - switch (c) { - case '"': - c = '\0'; - break; - case '\\': - escape = FcTrue; - continue; - } - } - if (i == size) - { - dest[i++] = 0; - return dest; - } - dest[i++] = c; - if (c == '\0') - return dest; - escape = FcFalse; + int slen; + dest[size] = '\0'; + slen = strlen (dest); + + lseek (fd, slen - size + 1, SEEK_CUR); + return slen < len ? dest : 0; } + return 0; } static void FcCacheSkipString (int fd) { - FcChar8 c; - FcBool escape; + char buf[256]; + int size; + int slen; - escape = FcFalse; - while (read (fd, &c, 1) == 1) + while ( (size = read (fd, buf, sizeof (buf)-1)) > 0) { - if (!escape) - { - switch (c) { - case '"': - c = '\0'; - break; - case '\\': - escape = FcTrue; - continue; - } - } - if (c == '\0') - return; - escape = FcFalse; + buf [size] = '\0'; + slen = strlen (buf); + if (slen < size) + { + lseek (fd, slen - size + 1, SEEK_CUR); + return; + } } - return; } static FcBool