Skip to content

Commit

Permalink
long --> compactlong
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Jan 12, 2025
1 parent 69112e9 commit fd88c8d
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
/* float-long */

static int
float_long_guard(PyObject *lhs, PyObject *rhs)
float_compactlong_guard(PyObject *lhs, PyObject *rhs)
{
return (
PyFloat_CheckExact(lhs) &&
Expand All @@ -2394,23 +2394,23 @@ float_long_guard(PyObject *lhs, PyObject *rhs)
Py_ssize_t rhs_val = _PyLong_CompactValue((PyLongObject *)rhs); \
return PyFloat_FromDouble(lhs_val OP rhs_val); \
}
FLOAT_LONG_ACTION(float_long_add, +)
FLOAT_LONG_ACTION(float_long_subtract, -)
FLOAT_LONG_ACTION(float_long_multiply, *)
FLOAT_LONG_ACTION(float_long_true_div, /)
FLOAT_LONG_ACTION(float_compactlong_add, +)
FLOAT_LONG_ACTION(float_compactlong_subtract, -)
FLOAT_LONG_ACTION(float_compactlong_multiply, *)
FLOAT_LONG_ACTION(float_compactlong_true_div, /)
#undef FLOAT_LONG_ACTION

static binaryopactionfunc float_long_actions[NB_OPARG_LAST+1] = {
[NB_ADD] = float_long_add,
[NB_SUBTRACT] = float_long_subtract,
[NB_TRUE_DIVIDE] = float_long_true_div,
[NB_INPLACE_MULTIPLY] = float_long_multiply,
static binaryopactionfunc float_compactlong_actions[NB_OPARG_LAST+1] = {
[NB_ADD] = float_compactlong_add,
[NB_SUBTRACT] = float_compactlong_subtract,
[NB_TRUE_DIVIDE] = float_compactlong_true_div,
[NB_INPLACE_MULTIPLY] = float_compactlong_multiply,
};

/* long-float */

static int
long_float_guard(PyObject *lhs, PyObject *rhs)
compactlong_float_guard(PyObject *lhs, PyObject *rhs)
{
return (
PyFloat_CheckExact(rhs) &&
Expand All @@ -2427,34 +2427,34 @@ long_float_guard(PyObject *lhs, PyObject *rhs)
Py_ssize_t lhs_val = _PyLong_CompactValue((PyLongObject *)lhs); \
return PyFloat_FromDouble(lhs_val OP rhs_val); \
}
LONG_FLOAT_ACTION(long_float_add, +)
LONG_FLOAT_ACTION(long_float_subtract, -)
LONG_FLOAT_ACTION(long_float_multiply, *)
LONG_FLOAT_ACTION(long_float_true_div, /)
LONG_FLOAT_ACTION(compactlong_float_add, +)
LONG_FLOAT_ACTION(compactlong_float_subtract, -)
LONG_FLOAT_ACTION(compactlong_float_multiply, *)
LONG_FLOAT_ACTION(compactlong_float_true_div, /)
#undef LONG_FLOAT_ACTION

static binaryopactionfunc long_float_actions[NB_OPARG_LAST+1] = {
[NB_ADD] = long_float_add,
[NB_SUBTRACT] = long_float_subtract,
[NB_TRUE_DIVIDE] = long_float_true_div,
[NB_INPLACE_MULTIPLY] = long_float_multiply,
static binaryopactionfunc compactlong_float_actions[NB_OPARG_LAST+1] = {
[NB_ADD] = compactlong_float_add,
[NB_SUBTRACT] = compactlong_float_subtract,
[NB_TRUE_DIVIDE] = compactlong_float_true_div,
[NB_INPLACE_MULTIPLY] = compactlong_float_multiply,
};

static int
binary_op_extended_specialization(PyObject *lhs, PyObject *rhs, int oparg,
binaryopguardfunc *guard, binaryopactionfunc *action)
{
if (long_float_actions[oparg]) {
if (long_float_guard(lhs, rhs)) {
*guard = long_float_guard;
*action = long_float_actions[oparg];
if (compactlong_float_actions[oparg]) {
if (compactlong_float_guard(lhs, rhs)) {
*guard = compactlong_float_guard;
*action = compactlong_float_actions[oparg];
return 1;
}
}
if (float_long_actions[oparg]) {
if (float_long_guard(lhs, rhs)) {
*guard = float_long_guard;
*action = float_long_actions[oparg];
if (float_compactlong_actions[oparg]) {
if (float_compactlong_guard(lhs, rhs)) {
*guard = float_compactlong_guard;
*action = float_compactlong_actions[oparg];
return 1;
}
}
Expand Down

0 comments on commit fd88c8d

Please sign in to comment.