From 016325dd0a5ad0904378004e728ccca19ee2b30d Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Tue, 18 Jul 2017 16:17:23 +1000
Subject: [PATCH] py/vm: Make n_state variable local to just set-up part of VM.

It's not used anywhere else in the VM loop, and clashes with (is shadowed
by) the n_state variable that's redeclared towards the end of the
mp_execute_bytecode function.  Code size is unchanged.
---
 py/vm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/py/vm.c b/py/vm.c
index 7451d53b9..bb120e775 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -162,9 +162,13 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp
 run_code_state: ;
 #endif
     // Pointers which are constant for particular invocation of mp_execute_bytecode()
-    size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode);
-    mp_obj_t * /*const*/ fastn = &code_state->state[n_state - 1];
-    mp_exc_stack_t * /*const*/ exc_stack = (mp_exc_stack_t*)(code_state->state + n_state);
+    mp_obj_t * /*const*/ fastn;
+    mp_exc_stack_t * /*const*/ exc_stack;
+    {
+        size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode);
+        fastn = &code_state->state[n_state - 1];
+        exc_stack = (mp_exc_stack_t*)(code_state->state + n_state);
+    }
 
     // variables that are visible to the exception handler (declared volatile)
     volatile bool currently_in_except_block = MP_TAGPTR_TAG0(code_state->exc_sp); // 0 or 1, to detect nested exceptions
-- 
GitLab