Module: deluge Branch: master Commit: 2a8b8e93dab38f04835dc5a68872ff1c7f043e3b
Author: Calum Lind <[email protected]> Date: Fri Dec 7 10:48:56 2012 +0000 Use try-except instead of if statement to gain a little performance --- deluge/core/torrentmanager.py | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index d60d785..2387741 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -571,12 +571,11 @@ class TorrentManager(component.Component): :raises InvalidTorrentError: if the torrent_id is not in the session """ - - if torrent_id not in self.torrents: + try: + torrent_name = self.torrents[torrent_id].get_status(["name"])["name"] + except KeyError: raise InvalidTorrentError("torrent_id not in session") - torrent_name = self.torrents[torrent_id].get_status(["name"])["name"] - # Emit the signal to the clients component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id)) -- 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.
