@@ -87,15 +87,19 @@ void mp_map_init(mp_map_t *map, size_t n) {
87
87
map -> used = 0 ;
88
88
map -> all_keys_are_qstrs = 1 ;
89
89
map -> is_fixed = 0 ;
90
+ #if !MICROPY_PY_MAP_ORDERED
90
91
map -> is_ordered = 0 ;
92
+ #endif
91
93
}
92
94
93
95
void mp_map_init_fixed_table (mp_map_t * map , size_t n , const mp_obj_t * table ) {
94
96
map -> alloc = n ;
95
97
map -> used = n ;
96
98
map -> all_keys_are_qstrs = 1 ;
97
99
map -> is_fixed = 1 ;
100
+ #if !MICROPY_PY_MAP_ORDERED
98
101
map -> is_ordered = 1 ;
102
+ #endif
99
103
map -> table = (mp_map_elem_t * )table ;
100
104
}
101
105
@@ -118,6 +122,7 @@ void mp_map_clear(mp_map_t *map) {
118
122
map -> table = NULL ;
119
123
}
120
124
125
+ #if !MICROPY_PY_MAP_ORDERED
121
126
STATIC void mp_map_rehash (mp_map_t * map ) {
122
127
size_t old_alloc = map -> alloc ;
123
128
size_t new_alloc = get_hash_alloc_greater_or_equal_to (map -> alloc + 1 );
@@ -136,6 +141,7 @@ STATIC void mp_map_rehash(mp_map_t *map) {
136
141
}
137
142
m_del (mp_map_elem_t , old_table , old_alloc );
138
143
}
144
+ #endif
139
145
140
146
// MP_MAP_LOOKUP behaviour:
141
147
// - returns NULL if not found, else the slot it was found in with key,value non-null
@@ -167,7 +173,10 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
167
173
}
168
174
169
175
// if the map is an ordered array then we must do a brute force linear search
170
- if (map -> is_ordered ) {
176
+ #if !MICROPY_PY_MAP_ORDERED
177
+ if (map -> is_ordered )
178
+ #endif
179
+ {
171
180
for (mp_map_elem_t * elem = & map -> table [0 ], * top = & map -> table [map -> used ]; elem < top ; elem ++ ) {
172
181
if (elem -> key == index || (!compare_only_ptrs && mp_obj_equal (elem -> key , index ))) {
173
182
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
@@ -206,6 +215,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
206
215
return NULL ;
207
216
#endif
208
217
}
218
+ #if !MICROPY_PY_MAP_ORDERED
209
219
210
220
// map is a hash table (not an ordered array), so do a hash lookup
211
221
@@ -294,6 +304,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
294
304
}
295
305
}
296
306
}
307
+ #endif // !MICROPY_PY_MAP_ORDERED
297
308
}
298
309
299
310
/******************************************************************************/
0 commit comments