speed improvement in combo matching code

This commit is contained in:
xs5871 2022-08-10 11:19:29 +00:00 committed by Kyle Brown
parent a1450de137
commit dafc969bf5

View File

@ -48,10 +48,10 @@ class Combo:
class Chord(Combo): class Chord(Combo):
def matches(self, key): def matches(self, key):
try: if key in self._remaining:
self._remaining.remove(key) self._remaining.remove(key)
return True return True
except ValueError: else:
return False return False
@ -61,9 +61,10 @@ class Sequence(Combo):
timeout = 1000 timeout = 1000
def matches(self, key): def matches(self, key):
try: if self._remaining and self._remaining[0] == key:
return key == self._remaining.pop(0) self._remaining.pop(0)
except IndexError: return True
else:
return False return False