Commit 3fa626a1 authored by Damien George's avatar Damien George

py/map: Add safety condition for case of adding to ordered maps.

This is to appease static analysers.  If MICROPY_PY_COLLECTIONS_ORDEREDDICT
is disabled then map->is_ordered implies map->is_fixed, and fixed maps are
only even called with MP_MAP_LOOKUP (see assert at start of the function),
so this new if statement should never be executed, it's only added to keep
static analysers happy.
parent 4f5d01cc
......@@ -137,6 +137,10 @@ STATIC void mp_map_rehash(mp_map_t *map) {
m_del(mp_map_elem_t, old_table, old_alloc);
static mp_map_elem_t dummy_map_elem; // Used to appease static analysers
// MP_MAP_LOOKUP behaviour:
// - returns NULL if not found, else the slot it was found in with key,value non-null
......@@ -202,6 +206,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
return elem;
if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { return &dummy_map_elem; } // To appease static analysers
return NULL;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment