Hi Dominik,

thanks for your reply and for the link. For fixing the krazy2 issues
correctly I changed QString to QLatin1String. I understand your point of
view with "readability" but I won't decide which way is better. I think the
explicit conversion of these Strings makes the understanding of the code not
so much harder...

You can find the modified patch in the attachment.

2009/1/15 Dominik Haumann <dh...@gmx.de>

> Hi Philipp,
>
> On Thursday 15 January 2009, Philipp Klaffert wrote:
> > @@ -54,7 +53,7 @@
> >          return true;
> >      }
> >
> > -    if (!name.startsWith("Timeline:") &&
> > !name.startsWith("TimelineWithFriends:")  &&
> > !name.startsWith("Profile:")) {
> > +    if
> > (!name.startsWith(QString("Timeline:")) &&
> > !name.startsWith(QString("TimelineWithFriends:"))  &&
> > !name.startsWith(QString("Profile:"))) { return false;
> >      }
>
> This is also what implicitly happens: const char* is implicitely converted
> to a QString. The right way is afaik to use QLatin1String, see also
> http://doc.trolltech.com/latest/qlatin1string.html for a better
> explanation :)
>
> And then, such optimizations should only be used in time critical cases, as
> the readability decreases when wrapping all strings (more text to read).
> But that's just my personal opinion, and maybe that's always the case in
> plasma - I don't know the preferred way here.
>
> Hope this helps :)
> Dominik
>
Index: dataengines/twitter/timelinesource.cpp
===================================================================
--- dataengines/twitter/timelinesource.cpp	(Revision 911365)
+++ dataengines/twitter/timelinesource.cpp	(Arbeitskopie)
@@ -76,7 +76,7 @@
       m_job(0)
 {
     //who should be something like u...@http://twitter.com, if there isn't any @, http://twitter.com will be the default
-    QStringList account = who.split("@");
+    QStringList account = who.split('@');
     if (account.count() == 2){
         m_serviceBaseUrl = KUrl(account.at(1));
     }else{
Index: dataengines/twitter/twitterengine.cpp
===================================================================
--- dataengines/twitter/twitterengine.cpp	(Revision 911365)
+++ dataengines/twitter/twitterengine.cpp	(Arbeitskopie)
@@ -30,7 +30,6 @@
 #include <KDebug>
 #include <KUrl>
 #include <ksocketfactory.h>
-#include <KUrl>
 
 #include "timelinesource.h"
 #include "imagesource.h"
@@ -54,7 +53,7 @@
         return true;
     }
 
-    if (!name.startsWith("Timeline:") && !name.startsWith("TimelineWithFriends:")  && !name.startsWith("Profile:")) {
+    if (!name.startsWith(QLatin1String("Timeline:")) && !name.startsWith(QLatin1String("TimelineWithFriends:"))  && !name.startsWith(QLatin1String("Profile:"))) {
         return false;
     }
 
@@ -83,17 +82,17 @@
 {
     //kDebug() << name;
     //right now it only makes sense to do an update on timelines
-    if (!name.startsWith("Timeline:") && !name.startsWith("TimelineWithFriends:") && !name.startsWith("Profile:")) {
+    if (!name.startsWith(QLatin1String("Timeline:")) && !name.startsWith(QLatin1String("TimelineWithFriends:")) && !name.startsWith(QLatin1String("Profile:"))) {
         return false;
     }
 
     TimelineSource::RequestType requestType;
 
     QString who = name;
-    if (name.startsWith("TimelineWithFriends:")) {
+    if (name.startsWith(QLatin1String("TimelineWithFriends:"))) {
         requestType = TimelineSource::TimelineWithFriends;
         who.remove("TimelineWithFriends:");
-    } else if (name.startsWith("Profile:")) {
+    } else if (name.startsWith(QLatin1String("Profile:"))) {
         requestType = TimelineSource::Profile;
         who.remove("Profile:");
     }else{
Index: dataengines/comic/comicproviderwrapper.cpp
===================================================================
--- dataengines/comic/comicproviderwrapper.cpp	(Revision 911365)
+++ dataengines/comic/comicproviderwrapper.cpp	(Arbeitskopie)
@@ -257,7 +257,7 @@
 
 void ComicProviderWrapper::init()
 {
-    const QString path = KStandardDirs::locate( "data", "plasma/comics/" + mProvider->pluginName() + "/" );
+    const QString path = KStandardDirs::locate( "data", "plasma/comics/" + mProvider->pluginName() + '/' );
     if ( !path.isEmpty() ) {
         mPackage = new Plasma::Package( path, ComicProviderKross::packageStructure() );
 
@@ -298,8 +298,8 @@
         foreach( const QString &interpretername, Kross::Manager::self().interpreters() ) {
             info = Kross::Manager::self().interpreterInfo( interpretername );
             wildcards = info->wildcard();
-            wildcards.replace( "*", "" );
-            mExtensions << wildcards.split( " " );
+            wildcards.replace( '*', "" );
+            mExtensions << wildcards.split( ' ' );
         }
     }
     return mExtensions;
Index: dataengines/comic/comicproviderwrapper.h
===================================================================
--- dataengines/comic/comicproviderwrapper.h	(Revision 911365)
+++ dataengines/comic/comicproviderwrapper.h	(Arbeitskopie)
@@ -38,7 +38,7 @@
         Q_PROPERTY( QImage image READ image WRITE setImage )
         Q_PROPERTY( QByteArray rawData READ rawData WRITE setRawData )
     public:
-        ImageWrapper( QObject *parent = 0, const QImage &image = QImage() );
+        explicit ImageWrapper( QObject *parent = 0, const QImage &image = QImage() );
 
         QImage image() const;
         void setImage( const QImage &image );
@@ -54,7 +54,7 @@
         Q_OBJECT
         Q_PROPERTY( QDate date READ date WRITE setDate )
     public:
-        DateWrapper( QObject *parent = 0, const QDate &date = QDate() );
+        explicit DateWrapper( QObject *parent = 0, const QDate &date = QDate() );
 
         QDate date() const;
         void setDate( const QDate &date );
Index: dataengines/comic/cachedprovider.cpp
===================================================================
--- dataengines/comic/cachedprovider.cpp	(Revision 911365)
+++ dataengines/comic/cachedprovider.cpp	(Arbeitskopie)
@@ -16,6 +16,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include "cachedprovider.h"
+
 #include <QtCore/QFile>
 #include <QtCore/QSettings>
 #include <QtCore/QTimer>
@@ -24,7 +26,6 @@
 #include <kstandarddirs.h>
 #include <KUrl>
 
-#include "cachedprovider.h"
 
 static QString identifierToPath( const QString &identifier )
 {
Index: dataengines/comic/cachedprovider.h
===================================================================
--- dataengines/comic/cachedprovider.h	(Revision 911365)
+++ dataengines/comic/cachedprovider.h	(Arbeitskopie)
@@ -37,7 +37,7 @@
          * @param identifier The identifier of the cached comic.
          * @param parent The parent object.
          */
-        CachedProvider( QObject *parent, const QVariantList &args = QVariantList() );
+        explicit CachedProvider( QObject *parent, const QVariantList &args = QVariantList() );
 
         /**
          * Destroys the cached provider.
Index: dataengines/comic/comic.cpp
===================================================================
--- dataengines/comic/comic.cpp	(Revision 911365)
+++ dataengines/comic/comic.cpp	(Arbeitskopie)
@@ -16,6 +16,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include "comic.h"
+
 #include <QtCore/QDate>
 #include <QtCore/QFileInfo>
 #include <QtCore/QSettings>
@@ -26,8 +28,6 @@
 
 #include <solid/networking.h>
 
-#include "comic.h"
-
 #include "cachedprovider.h"
 
 ComicEngine::ComicEngine( QObject* parent, const QVariantList& args )
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to