aboutsummaryrefslogtreecommitdiff
path: root/py/objfun.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-09-25 15:45:47 +1000
committerDamien George <damien.p.george@gmail.com>2019-10-01 12:26:22 +1000
commitc8c0fd4ca39fbdcf9ca5f2fc99ca4d6b81a28b65 (patch)
tree0fcbf3a263817be928c0b7db847d94293c79cce5 /py/objfun.c
parentb5ebfadbd615de42c43851f27a062bacd9147996 (diff)
py: Rework and compress second part of bytecode prelude.
This patch compresses the second part of the bytecode prelude which contains the source file name, function name, source-line-number mapping and cell closure information. This part of the prelude now begins with a single varible length unsigned integer which encodes 2 numbers, being the byte-size of the following 2 sections in the header: the "source info section" and the "closure section". After decoding this variable unsigned integer it's possible to skip over one or both of these sections very easily. This scheme saves about 2 bytes for most functions compared to the original format: one in the case that there are no closure cells, and one because padding was eliminated.
Diffstat (limited to 'py/objfun.c')
-rw-r--r--py/objfun.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objfun.c b/py/objfun.c
index 053fe46b7..7051f3476 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -139,7 +139,7 @@ const mp_obj_type_t mp_type_fun_builtin_var = {
/* byte code functions */
qstr mp_obj_code_get_name(const byte *code_info) {
- code_info = mp_decode_uint_skip(code_info); // skip code_info_size entry
+ MP_BC_PRELUDE_SIZE_DECODE(code_info);
#if MICROPY_PERSISTENT_CODE
return code_info[0] | (code_info[1] << 8);
#else