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

[tor-commits] [stem/master] Pre-emptively sort cached files



commit 41b63747e5b4a477b6eca3b72baf861a03047aaa
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Jul 22 15:49:50 2019 -0700

    Pre-emptively sort cached files
    
    Stupid me. There's no value in sorting filtered lists upon every query - might
    as well sort our cache so this only needs to be done once.
---
 stem/descriptor/collector.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/stem/descriptor/collector.py b/stem/descriptor/collector.py
index 426e48ae..bb9f1925 100644
--- a/stem/descriptor/collector.py
+++ b/stem/descriptor/collector.py
@@ -329,7 +329,7 @@ class CollecTor(object):
     """
 
     if not self._cached_files or time.time() - self._cached_index_at >= REFRESH_INDEX_RATE:
-      self._cached_files = CollecTor._files(self.index(), [])
+      self._cached_files = sorted(CollecTor._files(self.index(), []), key = lambda x: x.start if x.start else FUTURE)
 
     matches = []
 
@@ -342,8 +342,6 @@ class CollecTor(object):
       if descriptor_type is None or any([desc_type.startswith(descriptor_type) for desc_type in entry.guess_descriptor_types()]):
         matches.append(entry)
 
-    matches.sort(key = lambda x: x.start if x.start else FUTURE)
-
     return matches
 
   @staticmethod



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits