From a859bc67d575b3f509b0e52a2a929d3d1d1841b6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 15 Jan 2014 02:21:34 +0100 Subject: [PATCH] Don't bother setting undefined slots in array literal elisions. --- jscompile.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/jscompile.c b/jscompile.c index 4d2c75e..2816f53 100644 --- a/jscompile.c +++ b/jscompile.c @@ -172,12 +172,16 @@ static void carray(JF, js_Ast *list) { int i = 0; while (list) { - emit(J, F, OP_DUP); - emit(J, F, OP_NUMBER_X); - emit(J, F, i++); - cexp(J, F, list->a); - emit(J, F, OP_SETPROP); - emit(J, F, OP_POP); + if (list->a->type != EXP_UNDEF) { + emit(J, F, OP_DUP); + emit(J, F, OP_NUMBER_X); + emit(J, F, i++); + cexp(J, F, list->a); + emit(J, F, OP_SETPROP); + emit(J, F, OP_POP); + } else { + ++i; + } list = list->b; } } @@ -538,7 +542,6 @@ static void cexp(JF, js_Ast *exp) break; case EXP_LOGOR: - /* if a == true then a else b */ cexp(J, F, exp->a); emit(J, F, OP_DUP); end = jump(J, F, OP_JTRUE); @@ -548,7 +551,6 @@ static void cexp(JF, js_Ast *exp) break; case EXP_LOGAND: - /* if a == false then a else b */ cexp(J, F, exp->a); emit(J, F, OP_DUP); end = jump(J, F, OP_JFALSE);