mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Peephole constant folding had missed UNARY_POSITIVE.
This commit is contained in:
parent
42ead48dc1
commit
af7adad51d
3 changed files with 7 additions and 0 deletions
|
@ -197,6 +197,9 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
|
|||
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 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
|||
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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue