mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Remove unnecessary BINARY_OP_EQUAL code that just checks pointers.
Previous patch c38dc3ccc7 allowed any
object to be compared with any other, using pointer comparison for a
fallback. As such, existing code which checked for this case is no
longer needed.
This commit is contained in:
19
py/objfun.c
19
py/objfun.c
@@ -43,17 +43,9 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
// This binary_op method is used for all function types, and is also
|
||||
// used to determine if an object is of generic function type.
|
||||
mp_obj_t mp_obj_fun_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_EQUAL:
|
||||
// These objects can be equal only if it's the same underlying structure,
|
||||
// we don't even need to check for 2nd arg type.
|
||||
return MP_BOOL(lhs_in == rhs_in);
|
||||
}
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
}
|
||||
// Note: the "name" entry in mp_obj_type_t for a function type must be
|
||||
// MP_QSTR_function because it is used to determine if an object is of generic
|
||||
// function type.
|
||||
|
||||
/******************************************************************************/
|
||||
/* builtin functions */
|
||||
@@ -109,7 +101,6 @@ const mp_obj_type_t mp_type_fun_builtin = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_function,
|
||||
.call = fun_builtin_call,
|
||||
.binary_op = mp_obj_fun_binary_op,
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -264,7 +255,6 @@ const mp_obj_type_t mp_type_fun_bc = {
|
||||
.print = fun_bc_print,
|
||||
#endif
|
||||
.call = fun_bc_call,
|
||||
.binary_op = mp_obj_fun_binary_op,
|
||||
};
|
||||
|
||||
mp_obj_t mp_obj_new_fun_bc(mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code) {
|
||||
@@ -345,7 +335,6 @@ STATIC const mp_obj_type_t mp_type_fun_native = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_function,
|
||||
.call = fun_native_call,
|
||||
.binary_op = mp_obj_fun_binary_op,
|
||||
};
|
||||
|
||||
mp_obj_t mp_obj_new_fun_native(mp_uint_t n_args, void *fun_data) {
|
||||
@@ -404,7 +393,6 @@ STATIC const mp_obj_type_t mp_type_fun_viper = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_function,
|
||||
.call = fun_viper_call,
|
||||
.binary_op = mp_obj_fun_binary_op,
|
||||
};
|
||||
|
||||
mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig) {
|
||||
@@ -515,7 +503,6 @@ STATIC const mp_obj_type_t mp_type_fun_asm = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_function,
|
||||
.call = fun_asm_call,
|
||||
.binary_op = mp_obj_fun_binary_op,
|
||||
};
|
||||
|
||||
mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data) {
|
||||
|
||||
Reference in New Issue
Block a user