[GlyphCoordinates] Speed up __imul__()

Like the recent change to __isub__/__iadd__().

This, as well as the other, change do not handle overflows.
Going to fix that now.
This commit is contained in:
Behdad Esfahbod 2021-04-06 17:54:34 -06:00
parent 96690de9a9
commit 8be2f49b84

View File

@ -1705,12 +1705,18 @@ class GlyphCoordinates(object):
>>> g
GlyphCoordinates([(2, 4)])
"""
if isinstance(other, Number):
other = (other, other)
if isinstance(other, tuple):
assert len(other) == 2
self.scale(other)
return self
if isinstance(other, Number):
if other == 1.0: return self
if other == int(other): other = int(other)
if isinstance(other, float): self._ensureFloat()
a = self._a
for i in range(len(a)):
a[i] *= other
return self
return NotImplemented
def __itruediv__(self, other):