summaryrefslogtreecommitdiff
path: root/py/map.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-01-30 18:49:52 +1100
committerDamien George <damien.p.george@gmail.com>2019-02-12 14:54:51 +1100
commiteee1e8841a852f374b83e0a3e3b0ff7b66e54243 (patch)
treec928ad701fc0df71dc2863178ea8d2e8bea4946b /py/map.c
parent019433a17e82f22e8ee24ad1b53156403d4f4a67 (diff)
py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API.
These macros could in principle be (inline) functions so it makes sense to have them lower case, to match the other C API functions. The remaining macros that are upper case are: - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE - MP_OBJ_FUN_MAKE_SIG - MP_DECLARE_CONST_xxx - MP_DEFINE_CONST_xxx These must remain macros because they are used when defining const data (at least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have MP_OBJ_SMALL_INT_VALUE also a macro). For those macros that have been made lower case, compatibility macros are provided for the old names so that users do not need to change their code immediately.
Diffstat (limited to 'py/map.c')
-rw-r--r--py/map.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/py/map.c b/py/map.c
index fc5e1b1b7..fe08a9c6e 100644
--- a/py/map.c
+++ b/py/map.c
@@ -150,9 +150,9 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
// Work out if we can compare just pointers
bool compare_only_ptrs = map->all_keys_are_qstrs;
if (compare_only_ptrs) {
- if (MP_OBJ_IS_QSTR(index)) {
+ if (mp_obj_is_qstr(index)) {
// Index is a qstr, so can just do ptr comparison.
- } else if (MP_OBJ_IS_TYPE(index, &mp_type_str)) {
+ } else if (mp_obj_is_type(index, &mp_type_str)) {
// Index is a non-interned string.
// We can either intern the string, or force a full equality comparison.
// We chose the latter, since interning costs time and potentially RAM,
@@ -197,7 +197,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
}
mp_map_elem_t *elem = map->table + map->used++;
elem->key = index;
- if (!MP_OBJ_IS_QSTR(index)) {
+ if (!mp_obj_is_qstr(index)) {
map->all_keys_are_qstrs = 0;
}
return elem;
@@ -218,7 +218,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
// get hash of index, with fast path for common case of qstr
mp_uint_t hash;
- if (MP_OBJ_IS_QSTR(index)) {
+ if (mp_obj_is_qstr(index)) {
hash = qstr_hash(MP_OBJ_QSTR_VALUE(index));
} else {
hash = MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, index));
@@ -238,7 +238,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
}
avail_slot->key = index;
avail_slot->value = MP_OBJ_NULL;
- if (!MP_OBJ_IS_QSTR(index)) {
+ if (!mp_obj_is_qstr(index)) {
map->all_keys_are_qstrs = 0;
}
return avail_slot;
@@ -278,7 +278,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
map->used++;
avail_slot->key = index;
avail_slot->value = MP_OBJ_NULL;
- if (!MP_OBJ_IS_QSTR(index)) {
+ if (!mp_obj_is_qstr(index)) {
map->all_keys_are_qstrs = 0;
}
return avail_slot;