From affe47a11cdf0a9b8b94b99c0e305c259d779c0a Mon Sep 17 00:00:00 2001 From: bendikro Date: Sat, 25 May 2013 01:08:32 +0200 Subject: [PATCH] Cache items in get_filter_tree --- deluge/core/filtermanager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index 89dfd64ea..b8e5a77a4 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -34,6 +34,7 @@ # import logging +import copy import deluge.component as component STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"] @@ -130,6 +131,8 @@ class FilterManager(component.Component): self.register_filter("keyword", filter_keywords) self.register_filter("name", filter_by_name) self.tree_fields = {} + self.prev_filter_tree_keys = None + self.filter_tree_items = None self.register_tree_field("state", self._init_state_tree) def _init_tracker_tree(): @@ -211,7 +214,11 @@ class FilterManager(component.Component): tree_keys.remove(cat) torrent_keys, plugin_keys = self.torrents.separate_keys(tree_keys, torrent_ids) - items = dict((field, self.tree_fields[field]()) for field in tree_keys) + # Keys are the same, so use previous items + if self.prev_filter_tree_keys != tree_keys: + self.filter_tree_items = dict((field, self.tree_fields[field]()) for field in tree_keys) + self.prev_filter_tree_keys = tree_keys + items = copy.deepcopy(self.filter_tree_items) for torrent_id in list(torrent_ids): status = self.core.create_torrent_status(torrent_id, torrent_keys, plugin_keys) #status={key:value}