[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] kdelibs: QCString length caching
From: Andre Eisenbach <int2str () gmail ! com>
Date: 2004-10-27 3:57:07
Message-ID: 7f800d9f04102620571c92b0b8 () mail ! gmail ! com
[Download RAW message or body]
Hi!
Here is a patch for the QCString .length() caching based on the
automated test report posted on dot.kde.org.
More patches coming for the other issues.
Cheers,
Andre
["kdelibs_qstring.diff" (text/x-patch)]
Index: kdecore/kconfigbase.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfigbase.cpp,v
retrieving revision 1.182
diff -u -3 -p -r1.182 kconfigbase.cpp
--- kdecore/kconfigbase.cpp 7 Sep 2004 11:42:16 -0000 1.182
+++ kdecore/kconfigbase.cpp 27 Oct 2004 03:25:27 -0000
@@ -1325,11 +1325,13 @@ void KConfigBase::writeEntry ( const cha
{
uint i;
QString value;
+ uint nValueLength;
// !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
// A QStrList may contain values in 8bit locale cpecified
// encoding or in UTF8 encoding.
value = KStringHandler::from8Bit(it.current());
- for( i = 0; i < value.length(); i++ )
+ nValueLength = value.length();
+ for( i = 0; i < nValueLength; i++ )
{
if( value[i] == sep || value[i] == '\\' )
str_list += '\\';
@@ -1365,7 +1367,8 @@ void KConfigBase::writeEntry ( const cha
{
QString value = *it;
uint i;
- for( i = 0; i < value.length(); i++ )
+ uint nValueLength = value.length();
+ for( i = 0; i < nValueLength; i++ )
{
if( value[i] == sep || value[i] == '\\' )
str_list += '\\';
Index: kdesu/ssh.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdesu/ssh.cpp,v
retrieving revision 1.22
diff -u -3 -p -r1.22 ssh.cpp
--- kdesu/ssh.cpp 24 Feb 2003 15:50:36 -0000 1.22
+++ kdesu/ssh.cpp 27 Oct 2004 03:25:29 -0000
@@ -191,6 +191,7 @@ int SshProcess::ConverseSsh(const char *
unsigned i, j, colon;
QCString line;
+ uint nLineLength;
int state = 0;
while (state < 2)
@@ -209,7 +210,8 @@ int SshProcess::ConverseSsh(const char *
}
// Match "Password: " with the regex ^[^:]+:[\w]*$.
- for (i=0,j=0,colon=0; i<line.length(); i++)
+ nLineLength = line.length();
+ for (i=0,j=0,colon=0; i<nLineLength; i++)
{
if (line[i] == ':')
{
Index: kdesu/su.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdesu/su.cpp,v
retrieving revision 1.35
diff -u -3 -p -r1.35 su.cpp
--- kdesu/su.cpp 13 Apr 2004 13:33:21 -0000 1.35
+++ kdesu/su.cpp 27 Oct 2004 03:25:30 -0000
@@ -172,6 +172,7 @@ int SuProcess::ConverseSU(const char *pa
// kdDebug(900) << k_lineinfo << "ConverseSU starting." << endl;
QCString line;
+ uint nLineLength;
while (true)
{
line = readLine();
@@ -202,7 +203,8 @@ int SuProcess::ConverseSU(const char *pa
}
// Match "Password: " with the regex ^[^:]+:[\w]*$.
- for (i=0,j=0,colon=0; i<line.length(); i++)
+ nLineLength = line.length();
+ for (i=0,j=0,colon=0; i<nLineLength; i++)
{
if (line[i] == ':')
{
@@ -237,12 +239,14 @@ int SuProcess::ConverseSU(const char *pa
case CheckStar:
{
QCString s = line.stripWhiteSpace();
+ uint l;
if (s.isEmpty())
{
state=HandleStub;
break;
}
- for (i=0; i<s.length(); i++)
+ l = s.length();
+ for (i=0; i<l; i++)
{
if (s[i] != '*')
return error;
Index: kdeui/kpassdlg.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kpassdlg.cpp,v
retrieving revision 1.36
diff -u -3 -p -r1.36 kpassdlg.cpp
--- kdeui/kpassdlg.cpp 18 Jul 2004 09:59:16 -0000 1.36
+++ kdeui/kpassdlg.cpp 27 Oct 2004 03:25:30 -0000
@@ -114,7 +114,8 @@ KPasswordEdit::~KPasswordEdit()
void KPasswordEdit::insert(const QString &txt)
{
QCString localTxt = txt.local8Bit();
- for(unsigned int i=0; i < localTxt.length(); i++)
+ uint nLocalTxtLength = localTxt.length();
+ for(unsigned int i=0; i < nLocalTxtLength; i++)
{
unsigned char ke = localTxt[i];
if (m_Length < (PassLen - 1))
Index: khtml/html/html_formimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_formimpl.cpp,v
retrieving revision 1.392
diff -u -3 -p -r1.392 html_formimpl.cpp
--- khtml/html/html_formimpl.cpp 24 Oct 2004 16:42:23 -0000 1.392
+++ khtml/html/html_formimpl.cpp 27 Oct 2004 03:25:31 -0000
@@ -117,13 +117,15 @@ static QCString encodeCString(const QCSt
QCString encoded(( e.length()+e.contains( '\n' ) )*3
+e.contains('\r') * 3 + 1);
int enclen = 0;
+ uint estrlen = 0;
bool crmissing = false;
unsigned char oldc;
unsigned char c ='\0';
//QCString orig(e.data(), e.size());
- for(unsigned pos = 0; pos < e.length(); pos++) {
+ estrlen = e.length()l
+ for(unsigned pos = 0; pos < estrlen; pos++) {
oldc = c;
c = e[pos];
@@ -209,8 +211,14 @@ QByteArray HTMLFormElementImpl::formData
// find out the QTextcodec to use
QString str = m_acceptcharset.string();
+ uint nStrLen = str.length();
QChar space(' ');
- for(unsigned int i=0; i < str.length(); i++) if(str[i].latin1() == ',') str[i] = space;
+ for(unsigned int i=0; i < nStrLen; i++)
+ {
+ if(str[i].latin1() == ',')
+ str[i] = space;
+ }
+
QStringList charsets = QStringList::split(' ', str);
QTextCodec* codec = 0;
KHTMLView *view = getDocument()->view();
@@ -1251,9 +1259,10 @@ void HTMLInputElementImpl::attach()
if ((uint) m_type <= ISINDEX && !m_value.isEmpty()) {
QString value = m_value.string();
+ uint nValueLength = value.length();
// remove newline stuff..
QString nvalue;
- for (unsigned int i = 0; i < value.length(); ++i)
+ for (unsigned int i = 0; i < nValueLength; ++i)
if (value[i] >= ' ')
nvalue += value[i];
m_value = nvalue;
Index: kioslave/gzip/kgzipfilter.cpp
===================================================================
RCS file: /home/kde/kdelibs/kioslave/gzip/kgzipfilter.cpp,v
retrieving revision 1.12
diff -u -3 -p -r1.12 kgzipfilter.cpp
--- kioslave/gzip/kgzipfilter.cpp 22 Sep 2004 11:29:42 -0000 1.12
+++ kioslave/gzip/kgzipfilter.cpp 27 Oct 2004 03:25:31 -0000
@@ -206,6 +206,7 @@ bool KGzipFilter::writeHeader( const QCS
{
Bytef *p = d->zStream.next_out;
int i = d->zStream.avail_out;
+ uint nFileNameLength = fileName.length();
*p++ = 0x1f;
*p++ = 0x8b;
*p++ = Z_DEFLATED;
@@ -214,7 +215,7 @@ bool KGzipFilter::writeHeader( const QCS
*p++ = 0; // Extra flags (2=max compress, 4=fastest compress)
*p++ = 3; // Unix
- for ( uint j = 0 ; j < fileName.length() ; ++j )
+ for ( uint j = 0 ; j < nFileNameLength ; ++j )
*p++ = fileName[j];
*p++ = 0;
int headerSize = p - d->zStream.next_out;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic