From 6aaa1386198a34028e1288c2b6b3cec849a76db4 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Mon, 26 Sep 2016 07:50:57 -0400 Subject: [PATCH] Use a set instead of a list for Command._modes. --- qutebrowser/commands/command.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 16d9037d3..d899a543f 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -100,14 +100,14 @@ class Command: for m in modes: if not isinstance(m, usertypes.KeyMode): raise TypeError("Mode {} is no KeyMode member!".format(m)) - self._modes = modes + self._modes = set(modes) elif not_modes is not None: for m in not_modes: if not isinstance(m, usertypes.KeyMode): raise TypeError("Mode {} is no KeyMode member!".format(m)) - self._modes = [m for m in usertypes.KeyMode if m not in not_modes] + self._modes = set(usertypes.KeyMode).difference(not_modes) else: - self._modes = list(usertypes.KeyMode) + self._modes = set(usertypes.KeyMode) if scope != 'global' and instance is None: raise ValueError("Setting scope without setting instance makes " "no sense!") @@ -524,7 +524,7 @@ class Command: mode: The usertypes.KeyMode to check. """ if mode not in self._modes: - mode_names = '/'.join(m.name for m in self._modes) + mode_names = '/'.join(sorted(m.name for m in self._modes)) raise cmdexc.PrerequisitesError( "{}: This command is only allowed in {} mode, not {}.".format( self.name, mode_names, mode.name))