py/modstruct: Use more compact mp_raise_ValueError function.
Saves a few bytes of code size.
diff --git a/py/modstruct.c b/py/modstruct.c
index 2016add..be0d011 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -114,7 +114,7 @@
mp_uint_t align;
size_t sz = mp_binary_get_size(fmt_type, *fmt, &align);
if (sz == 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "unsupported format"));
+ mp_raise_ValueError("unsupported format");
}
while (cnt--) {
// Apply alignment
@@ -149,7 +149,7 @@
// negative offsets are relative to the end of the buffer
offset = bufinfo.len + offset;
if (offset < 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "buffer too small"));
+ mp_raise_ValueError("buffer too small");
}
}
p += offset;
@@ -164,7 +164,7 @@
sz = get_fmt_num(&fmt);
}
if (p + sz > end_p) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "buffer too small"));
+ mp_raise_ValueError("buffer too small");
}
mp_obj_t item;
if (*fmt == 's') {
@@ -197,7 +197,7 @@
sz = get_fmt_num(&fmt);
}
if (p + sz > end_p) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "buffer too small"));
+ mp_raise_ValueError("buffer too small");
}
if (*fmt == 's') {
@@ -240,7 +240,7 @@
// negative offsets are relative to the end of the buffer
offset = (mp_int_t)bufinfo.len + offset;
if (offset < 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "buffer too small"));
+ mp_raise_ValueError("buffer too small");
}
}
byte *p = (byte *)bufinfo.buf;