don't create the same QStrings over and over again, there is a

performance problem when a LOT of filters are used.

svn path=/trunk/kdenetwork/kmail/; revision=102437
wilder-work
Carsten Pfeiffer 25 years ago
parent b4a057a9ed
commit 71d189a84e
  1. 23
      kmsearchpattern.cpp

@ -5,6 +5,7 @@
#include "kmsearchpattern.h"
#include "kmmessage.h"
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include <kconfig.h>
@ -190,10 +191,13 @@ bool KMSearchRule::matches(const KMMessage* msg) const
void KMSearchRule::readConfig( KConfig *config, int aIdx )
{
char cIdx = char( int('A') + aIdx );
static const QString& field = KGlobal::staticQString( "field" );
static const QString& func = KGlobal::staticQString( "func" );
static const QString& contents = KGlobal::staticQString( "contents" );
init( config->readEntry( QString("field") + cIdx ),
config->readEntry( QString("func") + cIdx ).latin1(),
config->readEntry( QString("contents") + cIdx ) );
init( config->readEntry( field + cIdx ),
config->readEntry( func + cIdx ).latin1(),
config->readEntry( contents + cIdx ) );
}
@ -201,18 +205,23 @@ void KMSearchRule::readConfig( KConfig *config, int aIdx )
void KMSearchRule::writeConfig( KConfig *config, int aIdx ) const
{
char cIdx = char('A' + aIdx);
static const QString& field = KGlobal::staticQString( "field" );
static const QString& func = KGlobal::staticQString( "func" );
static const QString& contents = KGlobal::staticQString( "contents" );
config->writeEntry( QString("field") + cIdx, mField );
config->writeEntry( QString("func") + cIdx, funcConfigNames[(int)mFunction] );
config->writeEntry( QString("contents") + cIdx, mContents );
config->writeEntry( field + cIdx, mField );
config->writeEntry( func + cIdx, funcConfigNames[(int)mFunction] );
config->writeEntry( contents + cIdx, mContents );
}
//-----------------------------------------------------------------------------
bool KMSearchRule::isEmpty() const
{
bool ok;
static const QString& size = KGlobal::staticQString( "<size>" );
static const QString& ageInDays = KGlobal::staticQString( "<age in days>" );
if ( mField == "<size>" || mField == "<age in days>" ) {
if ( mField == size|| mField == ageInDays ) {
ok = FALSE;
mContents.toULong(&ok);
} else

Loading…
Cancel
Save