Fixed <rdar://problem/3823026> making isRoundingHackCharacter use -O3 and...
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 17:14:28 +0000 (17:14 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 17:14:28 +0000 (17:14 +0000)
        Careful testing shows a small performance gain on very large text files.
        I saw large variations in timings, but taking the lowest PLT timing
        with and without this change showed a 0.9% gain.  Note the cvs-base showed
        no improvement.  The improvement was for the large page attached to the
        bug.

        Reviewed by Ken.

        * WebCoreSupport.subproj/WebTextRenderer.m:
        (setupRoundingHackCharacterTable):
        (isRoundingHackCharacter):
        (+[WebTextRenderer initialize]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7836 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebTextRenderer.m

index d3dd6882282cb820a6805be83297494dc53c1196..77ef31803f774e56f7cfde2cac50ae26b17b822a 100644 (file)
@@ -1,3 +1,20 @@
+2004-10-14  Richard Williamson   <rjw@apple.com>
+
+        Fixed <rdar://problem/3823026> making isRoundingHackCharacter use -O3 and an 8-bit lookup-table will speed "XBS" test up by 3% (actually < 1%)
+
+        Careful testing shows a small performance gain on very large text files.  
+        I saw large variations in timings, but taking the lowest PLT timing 
+        with and without this change showed a 0.9% gain.  Note the cvs-base showed
+        no improvement.  The improvement was for the large page attached to the
+        bug.
+
+        Reviewed by Ken.
+
+        * WebCoreSupport.subproj/WebTextRenderer.m:
+        (setupRoundingHackCharacterTable):
+        (isRoundingHackCharacter):
+        (+[WebTextRenderer initialize]):
+
 2004-10-14  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by me
index 2ae682bfe4c2f08f2b4028c20b6ffcb0e8f68fdf..bed0674d5da9ade921be15b794e9a45f29ba9576 100644 (file)
@@ -181,9 +181,21 @@ static inline BOOL isSpace(UniChar c)
     return c == SPACE || isAlternateSpace(c);
 }
 
+static bool isRoundingHackCharacterTable[0xff];
+
+static void setupRoundingHackCharacterTable()
+{
+    bzero (isRoundingHackCharacterTable, 0xff);
+    isRoundingHackCharacterTable[0xA0] = 1;
+    isRoundingHackCharacterTable['\n'] = 1;
+    isRoundingHackCharacterTable[SPACE] = 1;
+    isRoundingHackCharacterTable['-'] = 1;
+    isRoundingHackCharacterTable['?'] = 1;
+}
+
 static inline BOOL isRoundingHackCharacter(UniChar c)
 {
-    return isSpace(c) || c == '-' || c == '?';
+    return (c & 0xFF00) != 0 && isRoundingHackCharacterTable[c] == 1;
 }
 
 
@@ -278,6 +290,7 @@ static BOOL alwaysUseATSU = NO;
 {
     nonBaseChars = CFCharacterSetGetPredefined(kCFCharacterSetNonBase);
     bufferTextDrawing = [[[NSUserDefaults standardUserDefaults] stringForKey:@"BufferTextDrawing"] isEqual: @"YES"];
+    setupRoundingHackCharacterTable();
 }
 
 - initWithFont:(NSFont *)f usingPrinterFont:(BOOL)p