aboutsummaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-09-27 11:22:33 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-27 11:22:33 +1000
commit76355c8863ce07a604e0a235ea460d4466747563 (patch)
tree9f1da9540e205996902b18b42774761f839d642a /py/vm.c
parent57a7d5be9ae3d367982c0f25b9f0215f58029faa (diff)
py/vm: Make small optimisation of BUILD_SLICE opcode.
No need to call DECODE_UINT since the value will always be either 2 or 3.
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/py/vm.c b/py/vm.c
index bc596b0e8..6d82824f2 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -817,17 +817,14 @@ unwind_jump:;
#if MICROPY_PY_BUILTINS_SLICE
ENTRY(MP_BC_BUILD_SLICE): {
MARK_EXC_IP_SELECTIVE();
- DECODE_UINT;
- if (unum == 2) {
- mp_obj_t stop = POP();
- mp_obj_t start = TOP();
- SET_TOP(mp_obj_new_slice(start, stop, mp_const_none));
- } else {
- mp_obj_t step = POP();
- mp_obj_t stop = POP();
- mp_obj_t start = TOP();
- SET_TOP(mp_obj_new_slice(start, stop, step));
+ mp_obj_t step = mp_const_none;
+ if (*ip++ == 3) {
+ // 3-argument slice includes step
+ step = POP();
}
+ mp_obj_t stop = POP();
+ mp_obj_t start = TOP();
+ SET_TOP(mp_obj_new_slice(start, stop, step));
DISPATCH();
}
#endif