diff Python/peephole.c @ 56667:27eaac07c5d6

Peephole constant folding had missed UNARY_POSITIVE.
author Raymond Hettinger <python@rcn.com>
date Thu, 22 Oct 2009 11:22:50 +0000
parents 3c4490ad01cf
children ed8b0ee1c531
line wrap: on
line diff
--- a/Python/peephole.c	Wed Oct 21 20:22:14 2009 +0000
+++ b/Python/peephole.c	Thu Oct 22 11:22:50 2009 +0000
@@ -197,6 +197,9 @@
 		case UNARY_INVERT:
 			newconst = PyNumber_Invert(v);
 			break;
+		case UNARY_POSITIVE:
+			newconst = PyNumber_Positive(v);
+			break;
 		default:
 			/* Called with an unknown opcode */
 			PyErr_Format(PyExc_SystemError,
@@ -500,6 +503,7 @@
 				   LOAD_CONST c1  UNARY_OP -->	LOAD_CONST unary_op(c) */
 			case UNARY_NEGATIVE:
 			case UNARY_INVERT:
+			case UNARY_POSITIVE:
 				if (lastlc >= 1	 &&
 				    ISBASICBLOCK(blocks, i-3, 4)  &&
 				    fold_unaryops_on_constants(&codestr[i-3], consts))	{