[vlmc-devel] RecentProjects: Use const QVariant& for toVariant()

Yikai Lu git at videolan.org
Tue Apr 12 14:28:03 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Apr 12 15:37:26 2016 +0900| [1c5715de4e574de8062b2f99cfa9ba57899f2bb8] | committer: Hugo Beauzée-Luyssen

RecentProjects: Use const QVariant& for toVariant()

I totally forgot that SettingValue::get() is already QVariant, which should be used directly to save some memory.

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/1c5715de4e574de8062b2f99cfa9ba57899f2bb8
---

 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:



More information about the Vlmc-devel mailing list