Author: andar
Revision: 5414
Log:
Use a more efficient sort to put the torrent state list in queue order
Diff:
Modified: trunk/deluge/core/torrentmanager.py
===================================================================
--- trunk/deluge/core/torrentmanager.py 2009-06-24 02:35:24 UTC (rev 5413)
+++ trunk/deluge/core/torrentmanager.py 2009-06-24 02:54:39 UTC (rev 5414)
@@ -37,10 +37,10 @@
"""TorrentManager handles Torrent objects"""
import cPickle
-import os.path
import os
import time
import shutil
+import operator
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
@@ -507,16 +507,9 @@
# Reorder the state.torrents list to add torrents in the correct queue
# order.
- ordered_state = []
- for torrent_state in state.torrents:
- for t in ordered_state:
- if torrent_state.queue < t.queue:
- ordered_state.insert(ordered_state.index(t), torrent_state)
- break
- if torrent_state not in ordered_state:
- ordered_state.append(torrent_state)
+ state.torrents.sort(key=operator.attrgetter("queue"))
- for torrent_state in ordered_state:
+ for torrent_state in state.torrents:
try:
self.add(state=torrent_state, save_state=False)
except AttributeError, e:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---