[gnome-music/wip/mschraal/grltrackerwrapper-small-optimization: 5/6] grltrackerwrapper: Minor artist albums filter optimization




commit 2a571d17620e7dda7c3632a3126752aa92f52232
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun May 1 15:35:12 2022 +0200

    grltrackerwrapper: Minor artist albums filter optimization
    
    More pythonic and faster.

 gnomemusic/grilowrappers/grltrackerwrapper.py | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 680ba409f..28c3eb76b 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -710,7 +710,7 @@ class GrlTrackerWrapper(GObject.GObject):
             'location_filter': self._tracker_wrapper.location_filter()
         }
 
-        albums: List[Grl.Media] = []
+        albums: List[str] = []
 
         def query_cb(
                 source: Grl.Source, op_id: int, media: Optional[Grl.Media],
@@ -727,15 +727,10 @@ class GrlTrackerWrapper(GObject.GObject):
                 self._notificationmanager.pop_loading()
                 return
 
-            albums.append(media)
+            albums.append(media.get_id())
 
-        def albums_filter(
-                corealbum: CoreAlbum, albums: List[Grl.Media]) -> bool:
-            for media in albums:
-                if media.get_id() == corealbum.props.media.get_id():
-                    return True
-
-            return False
+        def albums_filter(corealbum: CoreAlbum, albums: List[str]) -> bool:
+            return corealbum.props.media.get_id() in albums
 
         self.props.source.query(
             query, [Grl.METADATA_KEY_TITLE], self._fast_options, query_cb)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]