drivers/neopixel: Avoid heap alloc in fill().

Previously the use of `range(start,stop,step)` caused an allocation.
Replace with while loop.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/7934/head
Jim Mussared 2021-11-18 00:10:49 +11:00 zatwierdzone przez Damien George
rodzic 172a031dff
commit 841eeb158e
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -36,10 +36,14 @@ class NeoPixel:
def fill(self, v):
b = self.buf
for i in range(self.bpp):
l = len(self.buf)
bpp = self.bpp
for i in range(bpp):
c = v[i]
for j in range(self.ORDER[i], len(self.buf), self.bpp):
j = self.ORDER[i]
while j < l:
b[j] = c
j += bpp
def write(self):
# BITSTREAM_TYPE_HIGH_LOW = 0