diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-02-24 09:57:25 -0500 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-02-24 09:57:25 -0500 |
commit | 4b3da603248fd4e273853af9dd57fbb3c61a9e07 (patch) | |
tree | d735822574ab6d0997adc2096d2fc3dcc94340ca | |
parent | 6771adc75fc795c909fb3371b376906ef4285919 (diff) | |
download | micropython-4b3da603248fd4e273853af9dd57fbb3c61a9e07.tar.gz micropython-4b3da603248fd4e273853af9dd57fbb3c61a9e07.zip |
py/runtime: mp_raise_msg(): Accept NULL argument for message.
In this case, raise an exception without a message.
This would allow to shove few code bytes comparing to currently used
mp_raise_msg(..., "") pattern. (Actual savings depend on function code
alignment used by a particular platform.)
-rw-r--r-- | py/runtime.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c index db6a6f18f9..1c25350ec4 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1431,7 +1431,11 @@ void *m_malloc_fail(size_t num_bytes) { } NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { - nlr_raise(mp_obj_new_exception_msg(exc_type, msg)); + if (msg == NULL) { + nlr_raise(mp_obj_new_exception(exc_type)); + } else { + nlr_raise(mp_obj_new_exception_msg(exc_type, msg)); + } } NORETURN void mp_raise_ValueError(const char *msg) { |