summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-12-20 11:36:26 -0800
committerDylan Baker <dylan@pnwbakers.com>2016-12-21 17:18:39 -0800
commitbf2005c111289fcd7f55b92e64cfa8c43b9bfdbc (patch)
treee851408464368cfcb173a491a3c4cef5b83888fa /alot
parent899d3f4bb20441393182c3a5690566705e6b91aa (diff)
Don't use dict.keys when not necessary
It's pretty easy to get caught up using dict.keys (or iterkeys) when one doesn't need to. This patch corrects two cases where it's not needed, the first is the case of inclusion. ``x in mydict.keys()`` is equivalent to ``x in mydict``, but without the need to generate a list and walk it. The second case is when calling set() on a dict, ``set(mydict)`` will create a set object of the dict's keys, without the need to create one in memory and is significantly faster than ``set(mydict.keys())`` or even ``set(mydict.iterkeys())``.
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py3
-rw-r--r--alot/commands/envelope.py4
-rw-r--r--alot/db/manager.py2
3 files changed, 4 insertions, 5 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 2389ed1f..579fc029 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -303,8 +303,7 @@ class SearchBuffer(Buffer):
def focus_last(self):
if self.reversed:
self.body.set_focus(0)
- elif (self.result_count < 200) or \
- (self.sort_order not in self._REVERSE.keys()):
+ elif self.result_count < 200 or self.sort_order not in self._REVERSE:
self.consume_pipe()
num_lines = len(self.threadlist.get_lines())
self.body.set_focus(num_lines - 1)
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index da045046..062b059e 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -309,10 +309,10 @@ class EditCommand(Command):
# determine editable headers
edit_headers = set(settings.get('edit_headers_whitelist'))
if '*' in edit_headers:
- edit_headers = set(self.envelope.headers.keys())
+ edit_headers = set(self.envelope.headers)
blacklist = set(settings.get('edit_headers_blacklist'))
if '*' in blacklist:
- blacklist = set(self.envelope.headers.keys())
+ blacklist = set(self.envelope.headers)
edit_headers = edit_headers - blacklist
logging.info('editable headers: %s', edit_headers)
diff --git a/alot/db/manager.py b/alot/db/manager.py
index a1c0b8ed..3520ee63 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -381,7 +381,7 @@ class DBManager(object):
:rtype: (:class:`multiprocessing.Pipe`,
:class:`multiprocessing.Process`)
"""
- assert sort in self._sort_orders.keys()
+ assert sort in self._sort_orders
q = self.query(querystring)
q.set_sort(self._sort_orders[sort])
return self.async(q.search_threads, (lambda a: a.get_thread_id()))