summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-12-19 13:37:15 +1100
committerDamien George <damien.p.george@gmail.com>2017-12-19 13:37:15 +1100
commit136cb7f27c27ee128d3adab9850b74f6129c8732 (patch)
treec584e9ee972da9cf8a7867ff291f90c37a20d66c /py
parentf5fb68e94fe72a7d8c158a47c2374ee0cea0227c (diff)
py/map: Don't include ordered-dict mutating code when not needed.
Diffstat (limited to 'py')
-rw-r--r--py/map.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/map.c b/py/map.c
index 696c7a2ea..6abf4853f 100644
--- a/py/map.c
+++ b/py/map.c
@@ -170,6 +170,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
if (map->is_ordered) {
for (mp_map_elem_t *elem = &map->table[0], *top = &map->table[map->used]; elem < top; elem++) {
if (elem->key == index || (!compare_only_ptrs && mp_obj_equal(elem->key, index))) {
+ #if MICROPY_PY_COLLECTIONS_ORDEREDDICT
if (MP_UNLIKELY(lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND)) {
// remove the found element by moving the rest of the array down
mp_obj_t value = elem->value;
@@ -180,9 +181,11 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
elem->key = MP_OBJ_NULL;
elem->value = value;
}
+ #endif
return elem;
}
}
+ #if MICROPY_PY_COLLECTIONS_ORDEREDDICT
if (MP_LIKELY(lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)) {
return NULL;
}
@@ -198,6 +201,9 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
map->all_keys_are_qstrs = 0;
}
return elem;
+ #else
+ return NULL;
+ #endif
}
// map is a hash table (not an ordered array), so do a hash lookup