Commits

Anonymous committed ed0dac2

Issue 2260: Small peephole optimization -- eliminate unnecessary POP_TOP /JUMP_FORWARD 1 pairs.

Comments (0)

Files changed (1)

Python/peephole.c

 				cumlc = 0;
 				break;
 
+				/* Replace POP_TOP JUMP_FORWARD 1 POP_TOP 
+				   with    NOP NOP NOP NOP POP_TOP.           */
+			case POP_TOP:
+				if (UNCONDITIONAL_JUMP(codestr[i+1]) &&
+					GETJUMPTGT(codestr, i+1) == i+5 &&
+					codestr[i+4] == POP_TOP &&
+					ISBASICBLOCK(blocks,i,4))
+						memset(codestr+i, NOP, 4);
+				break;
+
 				/* Try to fold tuples of constants (includes a case for lists
 				   which are only used for "in" and "not in" tests).
 				   Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.