Skip to content

Commit 7dc9470

Browse files
committed
remove a duplication in polygon.c
1 parent 709f34c commit 7dc9470

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

shared-bindings/vectorio/Polygon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
1616

1717

18+
//| from typing import List, Tuple
1819
//|
1920
//| class Polygon:
2021
//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ):

shared-module/vectorio/Polygon.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
4242
if (tuple_len != 2) {
4343
mp_raise_ValueError_varg(translate("%q must be a tuple of length 2"), MP_QSTR_point);
4444
}
45-
if (!mp_obj_get_int_maybe(tuple_items[0], &self->points_list[2*i])) {
46-
self->len = 0;
47-
gc_free( self->points_list );
48-
self->points_list = NULL;
49-
mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point);
50-
}
51-
if (!mp_obj_get_int_maybe(tuple_items[1], &self->points_list[2*i + 1])) {
45+
if ( !mp_obj_get_int_maybe(tuple_items[ 0 ], &self->points_list[2*i ])
46+
|| !mp_obj_get_int_maybe(tuple_items[ 1 ], &self->points_list[2*i + 1])
47+
) {
5248
self->len = 0;
5349
gc_free( self->points_list );
5450
self->points_list = NULL;

0 commit comments

Comments
 (0)