mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Have set conversion replace existing constant if not used elsewhere.
This commit is contained in:
parent
4d81ac9ca8
commit
5e547969f8
1 changed files with 7 additions and 1 deletions
|
@ -570,7 +570,13 @@ try_set_conversion(unsigned char *codestr, PyObject *consts)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Append new constant onto consts list.*/
|
||||
/* Append new constant onto consts list or replace existing constant
|
||||
if there are no other references to it.*/
|
||||
if (constant->ob_refcnt == 1) {
|
||||
PyList_SET_ITEM(consts, arg, newconst);
|
||||
Py_DECREF(constant);
|
||||
return 1;
|
||||
}
|
||||
len_consts = PyList_GET_SIZE(consts);
|
||||
if (PyList_Append(consts, newconst)) {
|
||||
Py_DECREF(newconst);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue