mirror of
https://github.com/python/cpython.git
synced 2026-04-28 23:00:40 +00:00
gh-134584: Eliminate redundant refcounting in TO_BOOL_INT, TO_BOOL_LIST (GH-143759)
This commit is contained in:
parent
66e1399311
commit
c556786b8b
9 changed files with 1047 additions and 920 deletions
|
|
@ -400,19 +400,21 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_INT, (value -- res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
|
||||
op(_TO_BOOL_INT, (value -- res, v)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyLong_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
v = value;
|
||||
}
|
||||
|
||||
op(_TO_BOOL_LIST, (value -- res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
|
||||
op(_TO_BOOL_LIST, (value -- res, v)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
|
||||
if (!already_bool) {
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
}
|
||||
v = value;
|
||||
}
|
||||
|
||||
op(_TO_BOOL_NONE, (value -- res)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue