speed improvement in combo matching code
This commit is contained in:
parent
a1450de137
commit
dafc969bf5
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user