[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kdeui
From: Maks Orlovich <mo002j () mail ! rochester ! edu>
Date: 2003-06-08 17:48:46
[Download RAW message or body]
CVS commit by orlovich:
Small KGuiItem::plainText() speedup discussed a while ago on kde-opt. (un-QRegExp'ify)
Cuts may be 10-25ms or so of startup time depending on app here, which is in around 1-2%
or so range. (Note: measurements are noisy, though)
M +24 -3 kguiitem.cpp 1.15
--- kdelibs/kdeui/kguiitem.cpp #1.14:1.15
@@ -118,7 +118,28 @@ QString KGuiItem::text() const {
return d->m_text;
}
+
+
QString KGuiItem::plainText() const {
- QString stripped( d->m_text );
- stripped.replace( QRegExp( "&(?!&)" ), QString::null );
+ int len = d->m_text.length();
+
+ if (len == 0)
+ return d->m_text;
+
+ //Can assume len >= 1 from now on.
+ QString stripped;
+
+ int resultLength = 0;
+ stripped.setLength(len);
+
+ const QChar* data = d->m_text.unicode();
+ for (int pos = 1; pos < len; pos++)
+ {
+ //We pass through any non-ampersand character,
+ //and any ampersand that's preceeded by an ampersand
+ if (data[pos] != '&' || data[pos-1] == '&')
+ stripped[resultLength++] = data[pos];
+ }
+
+ stripped.truncate(resultLength);
return stripped;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic