[vlmc-devel] main.qml: Optimize findClipItem

Yikai Lu git at videolan.org
Thu Jul 6 14:12:13 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jul  6 19:28:52 2017 +0900| [4864cfcb1e1ac1464075aefd665614861ce86de1] | committer: Yikai Lu

main.qml: Optimize findClipItem

> https://code.videolan.org/videolan/vlmc/commit/4864cfcb1e1ac1464075aefd665614861ce86de1
---

 src/Gui/timeline/Clip.qml | 1 +
 src/Gui/timeline/main.qml | 7 ++-----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index c549241d..aa632443 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -211,6 +211,7 @@ Rectangle {
             selected = true;
         newTrackId = trackId;
         allClips.push( clip );
+        allClipsDict[uuid] = clip;
 
         updateEffects( workflow.clipInfo( uuid ) );
 
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index b53e569b..aed0ba73 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -18,6 +18,7 @@ Rectangle {
     property int maxZ: 100
     property int scale: 4
     property var allClips: [] // Actual clip item objects
+    property var allClipsDict: ({}) // Actual clip item objects
     property var selectedClips: [] // Actual clip item objects
     property var groups: [] // list of lists of clip uuids
     property var linkedClipsDict: ({}) // Uuid
@@ -166,11 +167,7 @@ Rectangle {
     }
 
     function findClipItem( uuid ) {
-        for ( var i = 0; i < allClips.length; ++i ) {
-            if ( uuid === allClips[i].uuid )
-                return allClips[i];
-        }
-        return null;
+        return allClipsDict[uuid];
     }
 
     function adjustTracks( trackType ) {



More information about the Vlmc-devel mailing list