]> granicus.if.org Git - python/commitdiff
Move NOP to end of code transformation.
authorRaymond Hettinger <python@rcn.com>
Thu, 24 Jun 2004 09:25:39 +0000 (09:25 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 24 Jun 2004 09:25:39 +0000 (09:25 +0000)
Python/compile.c

index ab4b533b6baecde150b8aa61ad937c282e4f8d82..16328b53e7d05c2f9aace208ff5a76cadb5399b1 100644 (file)
@@ -392,7 +392,8 @@ optimize_code(PyObject *code, PyObject* consts)
                opcode = codestr[i];
                switch (opcode) {
 
-               /* Replace UNARY_NOT JUMP_IF_FALSE with NOP JUMP_IF_TRUE */
+               /* Replace UNARY_NOT JUMP_IF_FALSE POP_TOP with 
+                  with    JUMP_IF_TRUE POP_TOP NOP */
                case UNARY_NOT:
                        if (codestr[i+1] != JUMP_IF_FALSE  ||
                            codestr[i+4] != POP_TOP  ||
@@ -401,8 +402,11 @@ optimize_code(PyObject *code, PyObject* consts)
                        tgt = GETJUMPTGT(codestr, (i+1));
                        if (codestr[tgt] != POP_TOP)
                                continue;
-                       codestr[i] = NOP;
-                       codestr[i+1] = JUMP_IF_TRUE;
+                       j = GETARG(codestr, i+1) + 1;
+                       codestr[i] = JUMP_IF_TRUE;
+                       SETARG(codestr, i, j);
+                       codestr[i+3] = POP_TOP;
+                       codestr[i+4] = NOP;
                        break;
 
                /* not a is b -->  a is not b