Skip to content

Commit 883c2f6

Browse files
authored
GH-131331: Rename "not" to "invert" (GH-131334)
1 parent 844765b commit 883c2f6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Include/internal/pycore_optimizer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ typedef struct _jit_opt_tuple {
202202

203203
typedef struct {
204204
uint8_t tag;
205-
bool not;
205+
bool invert;
206206
uint16_t value;
207207
} JitOptTruthiness;
208208

Python/optimizer_symbols.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _Py_uop_sym_is_const(JitOptContext *ctx, JitOptSymbol *sym)
115115
if (truthiness < 0) {
116116
return false;
117117
}
118-
make_const(sym, (truthiness ^ sym->truthiness.not) ? Py_True : Py_False);
118+
make_const(sym, (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False);
119119
return true;
120120
}
121121
return false;
@@ -140,7 +140,7 @@ _Py_uop_sym_get_const(JitOptContext *ctx, JitOptSymbol *sym)
140140
if (truthiness < 0) {
141141
return NULL;
142142
}
143-
PyObject *res = (truthiness ^ sym->truthiness.not) ? Py_True : Py_False;
143+
PyObject *res = (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False;
144144
make_const(sym, res);
145145
return res;
146146
}
@@ -291,7 +291,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
291291
}
292292
JitOptSymbol *value = allocation_base(ctx) + sym->truthiness.value;
293293
PyTypeObject *type = _Py_uop_sym_get_type(value);
294-
if (const_val == (sym->truthiness.not ? Py_False : Py_True)) {
294+
if (const_val == (sym->truthiness.invert ? Py_False : Py_True)) {
295295
// value is truthy. This is only useful for bool:
296296
if (type == &PyBool_Type) {
297297
_Py_uop_sym_set_const(ctx, value, Py_True);
@@ -498,7 +498,7 @@ _Py_uop_sym_truthiness(JitOptContext *ctx, JitOptSymbol *sym)
498498
if (truthiness < 0) {
499499
return truthiness;
500500
}
501-
truthiness ^= sym->truthiness.not;
501+
truthiness ^= sym->truthiness.invert;
502502
make_const(sym, truthiness ? Py_True : Py_False);
503503
return truthiness;
504504
}
@@ -592,8 +592,8 @@ JitOptSymbol *
592592
_Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
593593
{
594594
// It's clearer to invert this in the signature:
595-
bool not = !truthy;
596-
if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.not == not) {
595+
bool invert = !truthy;
596+
if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.invert == invert) {
597597
return value;
598598
}
599599
JitOptSymbol *res = sym_new(ctx);
@@ -603,11 +603,11 @@ _Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
603603
int truthiness = _Py_uop_sym_truthiness(ctx, value);
604604
if (truthiness < 0) {
605605
res->tag = JIT_SYM_TRUTHINESS_TAG;
606-
res->truthiness.not = not;
606+
res->truthiness.invert = invert;
607607
res->truthiness.value = (uint16_t)(value - allocation_base(ctx));
608608
}
609609
else {
610-
make_const(res, (truthiness ^ not) ? Py_True : Py_False);
610+
make_const(res, (truthiness ^ invert) ? Py_True : Py_False);
611611
}
612612
return res;
613613
}

0 commit comments

Comments
 (0)