[webkit-changes] cvs commit: WebCore/khtml/xml dom_atomicstring.cpp

Maciej mjs at opensource.apple.com
Thu Jul 7 22:19:21 PDT 2005


mjs         05/07/07 22:19:21

  Modified:    .        ChangeLog
               khtml/misc hashfunctions.h hashtable.h
               khtml/xml dom_atomicstring.cpp
  Log:
          Reviewed by hyatt.
  
          - sped up DOMStringImpl * equality comparisons.
  
          * khtml/misc/hashfunctions.h:
          (khtml::):
          * khtml/misc/hashtable.h:
          * khtml/xml/dom_atomicstring.cpp:
          (DOM::equal):
  
  Revision  Changes    Path
  1.4389    +12 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4388
  retrieving revision 1.4389
  diff -u -r1.4388 -r1.4389
  --- ChangeLog	8 Jul 2005 00:19:58 -0000	1.4388
  +++ ChangeLog	8 Jul 2005 05:19:14 -0000	1.4389
  @@ -1,3 +1,15 @@
  +2005-07-07  Maciej Stachowiak  <mjs at apple.com>
  +
  +        Reviewed by hyatt.
  +
  +        - sped up DOMStringImpl * equality comparisons.
  +
  +        * khtml/misc/hashfunctions.h:
  +        (khtml::):
  +        * khtml/misc/hashtable.h:
  +        * khtml/xml/dom_atomicstring.cpp:
  +        (DOM::equal):
  +
   2005-07-07  Adele Peterson  <adele at apple.com>
   
           change by Maciej, reviewed by me.
  
  
  
  1.2       +16 -6     WebCore/khtml/misc/hashfunctions.h
  
  Index: hashfunctions.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/misc/hashfunctions.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- hashfunctions.h	6 Jul 2005 01:28:42 -0000	1.1
  +++ hashfunctions.h	8 Jul 2005 05:19:20 -0000	1.2
  @@ -79,14 +79,24 @@
       {
           if (a == b) return true;
           if (!a || !b) return false;
  -        uint length = a->l;
  -        if (length != b->l)
  +
  +        uint aLength = a->l;
  +        uint bLength = b->l;
  +        if (aLength != bLength)
               return false;
  -        const QChar *as = a->s;
  -        const QChar *bs = b->s;
  -        for (uint i = 0; i != length; ++i)
  -            if (as[i] != bs[i])
  +
  +        const uint32_t *aChars = reinterpret_cast<const uint32_t *>(a->s);
  +        const uint32_t *bChars = reinterpret_cast<const uint32_t *>(b->s);
  +    
  +        uint halfLength = aLength >> 1;
  +        for (uint i = 0; i != halfLength; ++i) {
  +            if (*aChars++ != *bChars++)
                   return false;
  +        }
  +
  +        if (aLength & 1 && *reinterpret_cast<const uint16_t *>(aChars) != *reinterpret_cast<const uint16_t *>(bChars))
  +            return false;
  +
           return true;
       }
   };
  
  
  
  1.7       +1 -1      WebCore/khtml/misc/hashtable.h
  
  Index: hashtable.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/misc/hashtable.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- hashtable.h	7 Jul 2005 05:42:26 -0000	1.6
  +++ hashtable.h	8 Jul 2005 05:19:20 -0000	1.7
  @@ -28,7 +28,7 @@
   
   namespace khtml {
   
  -#define DUMP_HASHTABLE_STATS 0
  +#define DUMP_HASHTABLE_STATS 1
   #define CHECK_HASHTABLE_CONSISTENCY 0
   
   #if DUMP_HASHTABLE_STATS
  
  
  
  1.9       +20 -7     WebCore/khtml/xml/dom_atomicstring.cpp
  
  Index: dom_atomicstring.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_atomicstring.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- dom_atomicstring.cpp	6 Jul 2005 01:28:44 -0000	1.8
  +++ dom_atomicstring.cpp	8 Jul 2005 05:19:21 -0000	1.9
  @@ -98,17 +98,30 @@
       return DOMStringImpl::computeHash(buf.s, buf.length);
   }
   
  -inline bool equal(DOMStringImpl* const&r, const QCharBuffer &buf)
  +inline bool equal(DOMStringImpl* const& str, const QCharBuffer &buf)
   {
  -    if (!r && !buf.s) return true;
  -    if (!r || !buf.s) return false;
  +    const uint32_t *strChars = reinterpret_cast<const uint32_t *>(str->s);
  +    const uint32_t *bufChars = reinterpret_cast<const uint32_t *>(buf.s);
  +
  +    if (!strChars && !bufChars) return true;
  +    if (!strChars || !bufChars) return false;
       
  -    if (r->l != buf.length)
  +    uint strLength = str->l;
  +    uint bufLength = buf.length;
  +    if (strLength != bufLength)
           return false;
  -    const QChar *d = r->s;
  -    for (uint i = 0; i != buf.length; ++i)
  -        if (d[i] != buf.s[i])
  +
  +    
  +    uint halfLength = strLength >> 1;
  +    for (uint i = 0; i != halfLength; ++i) {
  +        if (*strChars++ != *bufChars++)
               return false;
  +    }
  +
  +    if (strLength & 1 && 
  +        *reinterpret_cast<const uint16_t *>(strChars) != *reinterpret_cast<const uint16_t *>(bufChars))
  +        return false;
  +
       return true;
   }
   
  
  
  



More information about the webkit-changes mailing list