commit 490949ca474ba1a9e8ac2de101f47e568e3f01b1
parent 054108ff4b21710b8e569d31cbd229da801c755a
Author: William Casarin <jb55@jb55.com>
Date: Sun, 8 Aug 2021 22:11:16 -0700
speed up find_label a bit
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/wasm.c b/src/wasm.c
@@ -4302,19 +4302,19 @@ static INLINE u16 *func_num_labels(struct wasm_interp *interp, u32 fn)
static int find_label(struct wasm_interp *interp, u32 fn, u32 instr_pos)
{
- u16 *num_labels, i;
+ u16 *num_labels;
+ int i;
struct label *label;
num_labels = func_num_labels(interp, fn);
- if (!(label = index_label(&interp->labels, fn, 0)))
+ if (!(label = index_label(&interp->labels, fn, *num_labels-1)))
return interp_error(interp, "index label");
- for (i = 0; i < *num_labels; label++) {
- assert((u8*)label < interp->labels.end);
+ for (i = *num_labels-1; i >= 0; label--) {
if (label_instr_pos(label) == instr_pos)
return i;
- i++;
+ i--;
}
return -1;