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>
Takashi Iwai <tiwai@suse.de>

View File

@ -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 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)
buf [size] = '\0';
slen = strlen (buf);
if (slen < size)
{
switch (c) {
case '"':
c = '\0';
break;
case '\\':
escape = FcTrue;
continue;
}
}
if (c == '\0')
lseek (fd, slen - size + 1, SEEK_CUR);
return;
escape = FcFalse;
}
return;
}
}
static FcBool