[vlmc-devel] [PATCH] RecentProjects: Use const QVariant& for toVariant()
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Tue Apr 12 14:25:32 CEST 2016
On 04/12/2016 08:37 AM, Yikai Lu wrote:
> I totally forgot that SettingValue::get() is already QVariant, which should be used directly to save some memory.
> ---
> src/Project/RecentProjects.cpp | 8 ++++----
> src/Project/RecentProjects.h | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/Project/RecentProjects.cpp b/src/Project/RecentProjects.cpp
> index 4985d5b..25f43b5 100644
> --- a/src/Project/RecentProjects.cpp
> +++ b/src/Project/RecentProjects.cpp
> @@ -30,16 +30,16 @@ RecentProjects::RecentProjects( Settings* vlmcSettings, QObject *parent )
> "", "", SettingValue::Private );
> }
>
> -QVariant
> +const QVariant&
> RecentProjects::toVariant() const
> {
> - return QVariant( m_recentsProjects->get().toList() );
> + return m_recentsProjects->get();
> }
>
> void
> RecentProjects::remove( const QString &projectFile )
> {
> - QVariantList l = m_recentsProjects->get().toList();
> + QVariantList l = toVariant().toList();
> for ( int i = 0; i < l.count(); ++i )
> {
> if ( l[i].toMap()["file"].toString() == projectFile )
> @@ -54,7 +54,7 @@ RecentProjects::remove( const QString &projectFile )
> void
> RecentProjects::projectLoaded( const QString& projectName, const QString& projectFile )
> {
> - QVariantList l = m_recentsProjects->get().toList();
> + QVariantList l = toVariant().toList();
> QVariantMap var {
> { "name", projectName },
> { "file", projectFile }
> diff --git a/src/Project/RecentProjects.h b/src/Project/RecentProjects.h
> index 82f5c44..6c5d6b3 100644
> --- a/src/Project/RecentProjects.h
> +++ b/src/Project/RecentProjects.h
> @@ -36,7 +36,7 @@ class RecentProjects : public QObject
> public:
> explicit RecentProjects(Settings* vlmcSettings, QObject *parent = 0 );
>
> - QVariant toVariant() const;
> + const QVariant& toVariant() const;
> void remove( const QString& projectFile );
>
> public slots:
>
Oh indeed, I should have spotted this during the review, sorry.
Applied!
More information about the Vlmc-devel
mailing list