[vlmc-devel] Library: Optimize adding files in database

Yikai Lu git at videolan.org
Wed Mar 8 18:40:23 CET 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Mar  8 11:39:52 2017 -0600| [1bd109af1d2ab8649338111c32cbbadc7558ef86] | committer: Yikai Lu

Library: Optimize adding files in database

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

 src/Library/Library.cpp | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 756f940..8168870 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -321,15 +321,6 @@ Library::onDiscoveryCompleted( const std::string& entryPoint )
         m_audioModel->refresh();
     }
 
-    // FIXME: Optimization Needed
-    for ( auto media : m_ml->videoFiles() )
-        if ( m_videoModel->findMedia( media->id() ) == nullptr )
-            m_videoModel->addMedia( media );
-
-    for ( auto media : m_ml->audioFiles() )
-        if ( m_audioModel->findMedia( media->id() ) == nullptr )
-            m_audioModel->addMedia( media );
-
     emit discoveryCompleted( QString::fromStdString( entryPoint ) );
 }
 
@@ -360,8 +351,16 @@ Library::onReloadStarted( const std::string& )
 }
 
 void
-Library::onReloadCompleted( const std::string& )
+Library::onReloadCompleted( const std::string& entryPoint )
 {
+    if ( entryPoint.empty() == true )
+    {
+        for ( auto media : m_ml->videoFiles() )
+            m_videoModel->addMedia( media );
+
+        for ( auto media : m_ml->audioFiles() )
+            m_audioModel->addMedia( media );
+    }
 }
 
 void



More information about the Vlmc-devel mailing list