From kde-commits Thu Jan 31 22:43:53 2008 From: Frank Osterfeld Date: Thu, 31 Jan 2008 22:43:53 +0000 To: kde-commits Subject: KDE/kdepim/akregator/src Message-Id: <1201819433.368956.30265.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120181944020668 SVN commit 769254 by osterfeld: Optimize: Avoid a particular stupid copy; revert shared_ptr usage in Article M +14 -3 article.cpp M +1 -1 articlemodel.cpp A shared.h [License: BSD] --- trunk/KDE/kdepim/akregator/src/article.cpp #769253:769254 @@ -25,6 +25,7 @@ #include "article.h" #include "feed.h" #include "feedstorage.h" +#include "shared.h" #include "storage.h" #include "utils.h" @@ -42,7 +43,7 @@ namespace Akregator { -struct Article::Private +struct Article::Private : public Shared { /** The status of the article is stored in an int, the bits having the following meaning: @@ -206,16 +207,26 @@ Article::Article(const Article &other) : d(new Private) { - d = other.d; + *this = other; } Article::~Article() { + if ( d->deref() ) + { + delete d; + d = 0; + } } Article &Article::operator=(const Article &other) { - d = other.d; + if (this != &other) { + other.d->ref(); + if (d && d->deref()) + delete d; + d = other.d; + } return *this; } --- trunk/KDE/kdepim/akregator/src/articlemodel.cpp #769253:769254 @@ -108,7 +108,7 @@ { if ( !index.isValid() || index.row() < 0 || index.row() >= d->articles.count() ) return QVariant(); - const Akregator::Article article = d->articles[ index.row() ]; + const Akregator::Article& article( d->articles[ index.row() ] ); if ( article.isNull() ) return QVariant();