]> git.wh0rd.org Git - fontconfig.git/commitdiff
Remove de-escaping logic because FcCacheWriteString doesn't escape anyway.
authorPatrick Lam <plam@MIT.EDU>
Tue, 7 Feb 2006 02:33:57 +0000 (02:33 +0000)
committerPatrick Lam <plam@MIT.EDU>
Tue, 7 Feb 2006 02:33:57 +0000 (02:33 +0000)
    Do blockwise reading instead of byte-wise for performance.

ChangeLog
src/fccache.c

index 8378d5de77ec476b27deb8071351f5f2eb2bf813..098f167ddb1bcb784b38cbfd4091d0ca5f60c087 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
index f2a41d4eae68defb58cce5fb8651ab9e29447505..dd03322bb64b1c140cde8bce2da6d1f70967861f 100644 (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    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