Remove de-escaping logic because FcCacheWriteString doesn't escape anyway.

Do blockwise reading instead of byte-wise for performance.
This commit is contained in:
Patrick Lam 2006-02-07 02:33:57 +00:00
parent 8b413bb62c
commit 799157dbbf
2 changed files with 32 additions and 48 deletions

View File

@ -1,3 +1,11 @@
2006-02-07 Dirk Mueller <dmueller@suse.com>
* 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 <plam@mit.edu> 2006-02-06 Patrick Lam <plam@mit.edu>
Takashi Iwai <tiwai@suse.de> Takashi Iwai <tiwai@suse.de>

View File

@ -82,68 +82,44 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16]);
static char * static char *
FcCacheReadString (int fd, char *dest, int len) FcCacheReadString (int fd, char *dest, int len)
{ {
FcChar8 c; int size;
FcBool escape; int slen;
int size;
int i;
if (len == 0) if (len == 0)
return 0; return 0;
size = len; size = read (fd, dest, len-1);
i = 0;
escape = FcFalse; if (size > 0)
while (read (fd, &c, 1) == 1)
{ {
if (!escape) int slen;
{ dest[size] = '\0';
switch (c) { slen = strlen (dest);
case '"':
c = '\0'; lseek (fd, slen - size + 1, SEEK_CUR);
break; return slen < len ? dest : 0;
case '\\':
escape = FcTrue;
continue;
}
}
if (i == size)
{
dest[i++] = 0;
return dest;
}
dest[i++] = c;
if (c == '\0')
return dest;
escape = FcFalse;
} }
return 0; return 0;
} }
static void static void
FcCacheSkipString (int fd) FcCacheSkipString (int fd)
{ {
FcChar8 c; char buf[256];
FcBool escape; int size;
int slen;
escape = FcFalse; while ( (size = read (fd, buf, sizeof (buf)-1)) > 0)
while (read (fd, &c, 1) == 1)
{ {
if (!escape) buf [size] = '\0';
{ slen = strlen (buf);
switch (c) { if (slen < size)
case '"': {
c = '\0'; lseek (fd, slen - size + 1, SEEK_CUR);
break; return;
case '\\': }
escape = FcTrue;
continue;
}
}
if (c == '\0')
return;
escape = FcFalse;
} }
return;
} }
static FcBool static FcBool