GH-131331: Rename "not" to "invert" (GH-131334)

This commit is contained in:
Bénédikt Tran 2025-03-21 00:59:41 +01:00 committed by GitHub
parent 844765b20f
commit 883c2f682b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View file

@ -202,7 +202,7 @@ typedef struct _jit_opt_tuple {
typedef struct { typedef struct {
uint8_t tag; uint8_t tag;
bool not; bool invert;
uint16_t value; uint16_t value;
} JitOptTruthiness; } JitOptTruthiness;

View file

@ -115,7 +115,7 @@ _Py_uop_sym_is_const(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) { if (truthiness < 0) {
return false; return false;
} }
make_const(sym, (truthiness ^ sym->truthiness.not) ? Py_True : Py_False); make_const(sym, (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False);
return true; return true;
} }
return false; return false;
@ -140,7 +140,7 @@ _Py_uop_sym_get_const(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) { if (truthiness < 0) {
return NULL; return NULL;
} }
PyObject *res = (truthiness ^ sym->truthiness.not) ? Py_True : Py_False; PyObject *res = (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False;
make_const(sym, res); make_const(sym, res);
return res; return res;
} }
@ -291,7 +291,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
} }
JitOptSymbol *value = allocation_base(ctx) + sym->truthiness.value; JitOptSymbol *value = allocation_base(ctx) + sym->truthiness.value;
PyTypeObject *type = _Py_uop_sym_get_type(value); PyTypeObject *type = _Py_uop_sym_get_type(value);
if (const_val == (sym->truthiness.not ? Py_False : Py_True)) { if (const_val == (sym->truthiness.invert ? Py_False : Py_True)) {
// value is truthy. This is only useful for bool: // value is truthy. This is only useful for bool:
if (type == &PyBool_Type) { if (type == &PyBool_Type) {
_Py_uop_sym_set_const(ctx, value, Py_True); _Py_uop_sym_set_const(ctx, value, Py_True);
@ -498,7 +498,7 @@ _Py_uop_sym_truthiness(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) { if (truthiness < 0) {
return truthiness; return truthiness;
} }
truthiness ^= sym->truthiness.not; truthiness ^= sym->truthiness.invert;
make_const(sym, truthiness ? Py_True : Py_False); make_const(sym, truthiness ? Py_True : Py_False);
return truthiness; return truthiness;
} }
@ -592,8 +592,8 @@ JitOptSymbol *
_Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy) _Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
{ {
// It's clearer to invert this in the signature: // It's clearer to invert this in the signature:
bool not = !truthy; bool invert = !truthy;
if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.not == not) { if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.invert == invert) {
return value; return value;
} }
JitOptSymbol *res = sym_new(ctx); JitOptSymbol *res = sym_new(ctx);
@ -603,11 +603,11 @@ _Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
int truthiness = _Py_uop_sym_truthiness(ctx, value); int truthiness = _Py_uop_sym_truthiness(ctx, value);
if (truthiness < 0) { if (truthiness < 0) {
res->tag = JIT_SYM_TRUTHINESS_TAG; res->tag = JIT_SYM_TRUTHINESS_TAG;
res->truthiness.not = not; res->truthiness.invert = invert;
res->truthiness.value = (uint16_t)(value - allocation_base(ctx)); res->truthiness.value = (uint16_t)(value - allocation_base(ctx));
} }
else { else {
make_const(res, (truthiness ^ not) ? Py_True : Py_False); make_const(res, (truthiness ^ invert) ? Py_True : Py_False);
} }
return res; return res;
} }