From c2a4e4effc81d8ab21bb014e34355643e5ca0da2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 11 May 2015 12:25:19 +0000 Subject: py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as the operator argument. Hashing for int, str and bytes still go via fast-path in mp_unary_op since they are the most common objects which need to be hashed. This lead to quite a bit of code cleanup, and should be more efficient if anything. It saves 176 bytes code space on Thumb2, and 360 bytes on x86. The only loss is that the error message "unhashable type" is now the more generic "unsupported type for __hash__". --- py/objint.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'py/objint.c') diff --git a/py/objint.c b/py/objint.c index 7c527d4ae..1ff89d6ce 100644 --- a/py/objint.c +++ b/py/objint.c @@ -259,10 +259,6 @@ char *mp_obj_int_formatted(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size, #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE -mp_int_t mp_obj_int_hash(mp_obj_t self_in) { - return MP_OBJ_SMALL_INT_VALUE(self_in); -} - bool mp_obj_int_is_positive(mp_obj_t self_in) { return mp_obj_get_int(self_in) >= 0; } -- cgit v1.2.3