[Python-checkins] python/dist/src/Python compile.c,2.322,2.323
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Aug 25 05:18:33 CEST 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32534
Modified Files:
compile.c
Log Message:
Simplify chains of conditional jumps.
(Suggested by Neal Norwitz.)
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.322
retrieving revision 2.323
diff -u -d -r2.322 -r2.323
--- compile.c 24 Aug 2004 04:34:16 -0000 2.322
+++ compile.c 25 Aug 2004 03:18:29 -0000 2.323
@@ -550,11 +550,34 @@
}
break;
+ /* Simplify conditional jump to conditional jump where the
+ result of the first test implies the success of a similar
+ test or the failure of the opposite test.
+ Arises in code like:
+ "a and b or c"
+ "a and b and c"
+ x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE z
+ x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE y+3
+ */
+ case JUMP_IF_FALSE:
+ case JUMP_IF_TRUE:
+ tgt = GETJUMPTGT(codestr, i);
+ j = codestr[tgt];
+ if (j == JUMP_IF_FALSE || j == JUMP_IF_TRUE) {
+ if (j == opcode) {
+ tgttgt = GETJUMPTGT(codestr, tgt) - i - 3;
+ SETARG(codestr, i, tgttgt);
+ } else {
+ tgt -= i;
+ SETARG(codestr, i, tgt);
+ }
+ break;
+ }
+ /* Intentional fallthrough */
+
/* Replace jumps to unconditional jumps */
case FOR_ITER:
case JUMP_FORWARD:
- case JUMP_IF_FALSE:
- case JUMP_IF_TRUE:
case JUMP_ABSOLUTE:
case CONTINUE_LOOP:
case SETUP_LOOP:
More information about the Python-checkins
mailing list