8000 py/stream: Simplify arg extraction logic for stream_ioctl. · mimoccc/circuitpython@657aef6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 657aef6

Browse files
committed
py/stream: Simplify arg extraction logic for stream_ioctl.
Saves 16 bytes of code. Also, use mp_obj_get_int_truncated to allow integers as big as a machine word to be passed as the value.
1 parent 6e87aeb commit 657aef6
8000

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

py/stream.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,10 @@ STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
416416
mp_buffer_info_t bufinfo;
417417
uintptr_t val = 0;
418418
if (n_args > 2) {
419-
if (MP_OBJ_IS_INT(args[2])) {
420-
val = mp_obj_get_int(args[2]);
421-
} else {
422-
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
419+
if (mp_get_buffer(args[2], &bufinfo, MP_BUFFER_WRITE)) {
423420
val = (uintptr_t)bufinfo.buf;
421+
} else {
422+
val = mp_obj_get_int_truncated(args[2]);
424423
}
425424
}
426425

0 commit comments

Comments
 (0)
0