Skip to content

Commit 4b3da60

Browse files
committed
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.)
1 parent 6771adc commit 4b3da60

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

py/runtime.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,11 @@ void *m_malloc_fail(size_t num_bytes) {
14311431
}
14321432

14331433
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) {
1434-
nlr_raise(mp_obj_new_exception_msg(exc_type, msg));
1434+
if (msg == NULL) {
1435+
nlr_raise(mp_obj_new_exception(exc_type));
1436+
} else {
1437+
nlr_raise(mp_obj_new_exception_msg(exc_type, msg));
1438+
}
14351439
}
14361440

14371441
NORETURN void mp_raise_ValueError(const char *msg) {

0 commit comments

Comments
 (0)