Skip to content

Commit e2d252a

Browse files
committed
pre-allocate list of known size
1 parent efeae0d commit e2d252a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shared-module/vectorio/Polygon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t po
6969

7070
mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self) {
7171
VECTORIO_POLYGON_DEBUG("%p common_hal_vectorio_polygon_get_points {len: %d, points_list: %p}\n", self, self->len, self->points_list);
72-
mp_obj_t list = mp_obj_new_list(0, NULL);
72+
mp_obj_t list = mp_obj_new_list(self->len/2, NULL);
7373

7474
for (size_t i = 0; i < self->len; i += 2) {
7575
mp_obj_t tuple[] = { mp_obj_new_int(self->points_list[i]), mp_obj_new_int(self->points_list[i+1]) };

0 commit comments

Comments
 (0)