diff options
| author | Damien George <damien@micropython.org> | 2021-07-14 23:25:18 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-07-15 00:12:41 +1000 |
| commit | 74085f167e09694f1d32d3fb3d212066091f9f7d (patch) | |
| tree | d2861d4bfe678ae0699e01461cc597a8da215b83 /py | |
| parent | 38a204ed9605a9233a66c86538562fab821ce63a (diff) | |
py/modsys: Optimise sys.exit for code size by using exception helpers.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
| -rw-r--r-- | py/modsys.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/py/modsys.c b/py/modsys.c index 586b13e74..64349f3c3 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -110,13 +110,11 @@ STATIC const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM); // exit([retval]): raise SystemExit, with optional argument given to the exception STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { - mp_obj_t exc; if (n_args == 0) { - exc = mp_obj_new_exception(&mp_type_SystemExit); + mp_raise_type(&mp_type_SystemExit); } else { - exc = mp_obj_new_exception_arg1(&mp_type_SystemExit, args[0]); + mp_raise_type_arg(&mp_type_SystemExit, args[0]); } - nlr_raise(exc); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit); |
