Skip to content

Commit 561daaf

Browse files
committed
Address code review
1 parent 1d54f5c commit 561daaf

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

Include/internal/pycore_optimizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ extern JitOptRef _Py_uop_sym_new_type(
394394
extern JitOptRef _Py_uop_sym_new_const(JitOptContext *ctx, PyObject *const_val);
395395
extern JitOptRef _Py_uop_sym_new_const_steal(JitOptContext *ctx, PyObject *const_val);
396396
bool _Py_uop_sym_is_safe_const(JitOptContext *ctx, JitOptRef sym);
397-
bool _Py_uop_sym_is_container(JitOptRef sym);
397+
bool _Py_uop_sym_is_not_container(JitOptRef sym);
398398
_PyStackRef _Py_uop_sym_get_const_as_stackref(JitOptContext *ctx, JitOptRef sym);
399399
extern JitOptRef _Py_uop_sym_new_null(JitOptContext *ctx);
400400
extern bool _Py_uop_sym_has_type(JitOptRef sym);

Python/optimizer_analysis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ add_op(JitOptContext *ctx, _PyUOpInstruction *this_instr,
252252
#define sym_is_not_null _Py_uop_sym_is_not_null
253253
#define sym_is_const _Py_uop_sym_is_const
254254
#define sym_is_safe_const _Py_uop_sym_is_safe_const
255-
#define sym_is_container _Py_uop_sym_is_container
255+
#define sym_is_not_container _Py_uop_sym_is_not_container
256256
#define sym_get_const _Py_uop_sym_get_const
257257
#define sym_new_const_steal _Py_uop_sym_new_const_steal
258258
#define sym_get_const_as_stackref _Py_uop_sym_get_const_as_stackref

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ dummy_func(void) {
515515
res = sym_new_not_null(ctx);
516516
ds = dict_st;
517517
ss = sub_st;
518-
if (!sym_is_container(sub_st) &&
518+
if (sym_is_not_container(sub_st) &&
519519
sym_matches_type(dict_st, &PyFrozenDict_Type)) {
520520
REPLACE_OPCODE_IF_EVALUATES_PURE(dict_st, sub_st, res);
521521
}
@@ -707,7 +707,7 @@ dummy_func(void) {
707707
b = sym_new_type(ctx, &PyBool_Type);
708708
l = left;
709709
r = right;
710-
if (!sym_is_container(left) &&
710+
if (sym_is_not_container(left) &&
711711
sym_matches_type(right, &PyFrozenSet_Type)) {
712712
REPLACE_OPCODE_IF_EVALUATES_PURE(left, right, b);
713713
}

Python/optimizer_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_symbols.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,17 @@ _Py_uop_sym_is_safe_const(JitOptContext *ctx, JitOptRef sym)
288288
}
289289

290290
bool
291-
_Py_uop_sym_is_container(JitOptRef sym)
291+
_Py_uop_sym_is_not_container(JitOptRef sym)
292292
{
293293
PyTypeObject *typ = _Py_uop_sym_get_type(sym);
294294
if (typ == NULL) {
295295
return false;
296296
}
297-
return (typ == &PyFrozenSet_Type) ||
298-
(typ == &PyFrozenDict_Type) ||
299-
(typ == &PySet_Type) ||
300-
(typ == &PyDict_Type) ||
301-
(typ == &PyList_Type) ||
302-
(typ == &PyTuple_Type);
297+
return (typ == &PyLong_Type) ||
298+
(typ == &PyFloat_Type) ||
299+
(typ == &PyUnicode_Type) ||
300+
(typ == &_PyNone_Type) ||
301+
(typ == &PyBool_Type);
303302
}
304303

305304
void

0 commit comments

Comments
 (0)