Skip to content

Commit 6e03ff2

Browse files
authored
gh-126513: Use helpers for _Py_Specialize_ConstainsOp (#126517)
* Use helpers for _Py_Specialize_ConstainsOp * Remove unnecessary variable
1 parent 8fa4dc4 commit 6e03ff2

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

Python/specialize.c

+7-17
Original file line numberDiff line numberDiff line change
@@ -2760,8 +2760,8 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27602760
cache->counter = adaptive_counter_cooldown();
27612761
}
27622762

2763-
#ifdef Py_STATS
2764-
static int containsop_fail_kind(PyObject *value) {
2763+
static int
2764+
containsop_fail_kind(PyObject *value) {
27652765
if (PyUnicode_CheckExact(value)) {
27662766
return SPEC_FAIL_CONTAINS_OP_STR;
27672767
}
@@ -2776,7 +2776,6 @@ static int containsop_fail_kind(PyObject *value) {
27762776
}
27772777
return SPEC_FAIL_OTHER;
27782778
}
2779-
#endif // Py_STATS
27802779

27812780
void
27822781
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
@@ -2785,26 +2784,17 @@ _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
27852784

27862785
assert(ENABLE_SPECIALIZATION_FT);
27872786
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
2788-
uint8_t specialized_op;
2789-
_PyContainsOpCache *cache = (_PyContainsOpCache *)(instr + 1);
27902787
if (PyDict_CheckExact(value)) {
2791-
specialized_op = CONTAINS_OP_DICT;
2792-
goto success;
2788+
specialize(instr, CONTAINS_OP_DICT);
2789+
return;
27932790
}
27942791
if (PySet_CheckExact(value) || PyFrozenSet_CheckExact(value)) {
2795-
specialized_op = CONTAINS_OP_SET;
2796-
goto success;
2792+
specialize(instr, CONTAINS_OP_SET);
2793+
return;
27972794
}
27982795

2799-
SPECIALIZATION_FAIL(CONTAINS_OP, containsop_fail_kind(value));
2800-
STAT_INC(CONTAINS_OP, failure);
2801-
SET_OPCODE_OR_RETURN(instr, CONTAINS_OP);
2802-
cache->counter = adaptive_counter_backoff(cache->counter);
2796+
unspecialize(instr, containsop_fail_kind(value));
28032797
return;
2804-
success:
2805-
STAT_INC(CONTAINS_OP, success);
2806-
SET_OPCODE_OR_RETURN(instr, specialized_op);
2807-
cache->counter = adaptive_counter_cooldown();
28082798
}
28092799

28102800
/* Code init cleanup.

0 commit comments

Comments
 (0)