aboutsummaryrefslogtreecommitdiff
path: root/py/modstruct.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-08-26 23:42:40 +1000
committerDamien George <damien.p.george@gmail.com>2016-08-26 23:42:40 +1000
commitfe3cc5bb53198cc1462fb6748137d57a68960933 (patch)
tree0d6a5094424e66da2f0449eb63c9eb27367abbd5 /py/modstruct.c
parent3b5affa0d1f7c1e81dd4a48bba2742e8013804da (diff)
py/modstruct: Use more compact mp_raise_ValueError function.
Saves a few bytes of code size.
Diffstat (limited to 'py/modstruct.c')
-rw-r--r--py/modstruct.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/modstruct.c b/py/modstruct.c
index 2016add17..be0d0110d 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -114,7 +114,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
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 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
// 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 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
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 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, byte* end_p, siz
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 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
// 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;