shithub: libmujs

Download patch

ref: a859bc67d575b3f509b0e52a2a929d3d1d1841b6
parent: 47e88ac80569849e458b22b67341e19acd9af5a7
author: Tor Andersson <[email protected]>
date: Tue Jan 14 21:21:34 EST 2014

Don't bother setting undefined slots in array literal elisions.

--- a/jscompile.c
+++ b/jscompile.c
@@ -172,12 +172,16 @@
 {
 	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 @@
 		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 @@
 		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);