[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/khtml/html
From:       Viacheslav Tokarev <tsjoker () gmail ! com>
Date:       2009-03-14 17:48:23
Message-ID: 1237052903.564387.21752.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 939356 by vtokarev:

Avoid usage of QVector as temporary buffers. .clear() on it triggers
internal buffer deletion and shrinking capacity to 0. Which is not good
if you want to append something to it afterwards.
Replacing with saner WTF::Vector and QVarLengthArray, which gives significant
improvement for ProspectiveTokenizer. And less allocations too.
don't ever use QVector if you want to clear it a lot

 M  +3 -2      htmlprospectivetokenizer.cpp  
 M  +7 -7      htmlprospectivetokenizer.h  


--- trunk/KDE/kdelibs/khtml/html/htmlprospectivetokenizer.cpp #939355:939356
@@ -28,6 +28,7 @@
 #include "htmlprospectivetokenizer.h"
 
 #include <QTime>
+#include <QVarLengthArray>
 
 #include "html_headimpl.h"
 #include "html_documentimpl.h"
@@ -196,8 +197,8 @@
     };
     EntityState entityState = Initial;
     unsigned result = 0;
-    QVector<QChar> seenChars(10);
-    QVector<char> entityName(10);
+    QVarLengthArray<QChar> seenChars;
+    QVarLengthArray<char>  entityName;
     
     while (!source.isEmpty()) {
         seenChars.append(*source);
--- trunk/KDE/kdelibs/khtml/html/htmlprospectivetokenizer.h #939355:939356
@@ -27,7 +27,7 @@
 #define htmlprospectivetokenizer_h
 
 #include "misc/stringit.h"
-#include <QVector>
+#include <wtf/Vector.h>
 
 namespace DOM {
     class DocumentImpl;
@@ -109,10 +109,10 @@
         unsigned m_lastCharacterIndex;
         
         bool m_closeTag;
-        QVector<char> m_tagName;
-        QVector<char> m_attributeName;
-        QVector<QChar> m_attributeValue;
-        QVector<char> m_lastStartTag;
+        WTF::Vector<char, 8> m_tagName;
+        WTF::Vector<char, 8> m_attributeName;
+        WTF::Vector<QChar, 32> m_attributeValue;
+        WTF::Vector<char, 8> m_lastStartTag;
         uint m_lastStartTagId;
         
         DOM::DOMString m_urlToLoad;
@@ -130,8 +130,8 @@
             CSSAferRuleValue
         };
         CSSState m_cssState;
-        QVector<QChar> m_cssRule;
-        QVector<QChar> m_cssRuleValue;
+        WTF::Vector<QChar> m_cssRule;
+        WTF::Vector<QChar> m_cssRuleValue;
         
         int m_timeUsed;
         
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic