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.
This commit is contained in:
parent
6e87aeb841
commit
657aef66ff
@ -416,11 +416,10 @@ STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
|
|||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
uintptr_t val = 0;
|
uintptr_t val = 0;
|
||||||
if (n_args > 2) {
|
if (n_args > 2) {
|
||||||
if (MP_OBJ_IS_INT(args[2])) {
|
if (mp_get_buffer(args[2], &bufinfo, MP_BUFFER_WRITE)) {
|
||||||
val = mp_obj_get_int(args[2]);
|
|
||||||
} else {
|
|
||||||
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
|
|
||||||
val = (uintptr_t)bufinfo.buf;
|
val = (uintptr_t)bufinfo.buf;
|
||||||
|
} else {
|
||||||
|
val = mp_obj_get_int_truncated(args[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user