Skip to content

Commit 054dd33

Browse files
committed
py: Downcase MP_xxx_SLOT_IS_FILLED inline functions.
1 parent eee1e88 commit 054dd33

9 files changed

Lines changed: 17 additions & 15 deletions

File tree

‎py/builtinhelp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
5858
#if MICROPY_PY_BUILTINS_HELP_MODULES
5959
STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
6060
for (size_t i = 0; i < map->alloc; i++) {
61-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
61+
if (mp_map_slot_is_filled(map, i)) {
6262
mp_obj_list_append(list, map->table[i].key);
6363
}
6464
}

‎py/map.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t looku
395395

396396
mp_obj_t mp_set_remove_first(mp_set_t *set) {
397397
for (size_t pos = 0; pos < set->alloc; pos++) {
398-
if (MP_SET_SLOT_IS_FILLED(set, pos)) {
398+
if (mp_set_slot_is_filled(set, pos)) {
399399
mp_obj_t elem = set->table[pos];
400400
// delete element
401401
set->used--;

‎py/modbuiltins.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
178178
// Make a list of names in the local namespace
179179
mp_obj_dict_t *dict = mp_locals_get();
180180
for (size_t i = 0; i < dict->map.alloc; i++) {
181-
if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
181+
if (mp_map_slot_is_filled(&dict->map, i)) {
182182
mp_obj_list_append(dir, dict->map.table[i].key);
183183
}
184184
}

‎py/modthread.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
242242
th_args->n_kw = map->used;
243243
// copy across the keyword arguments
244244
for (size_t i = 0, n = pos_args_len; i < map->alloc; ++i) {
245-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
245+
if (mp_map_slot_is_filled(map, i)) {
246246
th_args->args[n++] = map->table[i].key;
247247
th_args->args[n++] = map->table[i].value;
248248
}

‎py/obj.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ typedef enum _mp_map_lookup_kind_t {
362362

363363
extern const mp_map_t mp_const_empty_map;
364364

365-
static inline bool MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL); }
365+
static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL); }
366366

367367
void mp_map_init(mp_map_t *map, size_t n);
368368
void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table);
@@ -381,7 +381,7 @@ typedef struct _mp_set_t {
381381
mp_obj_t *table;
382382
} mp_set_t;
383383

384-
static inline bool MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL); }
384+
static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL); }
385385

386386
void mp_set_init(mp_set_t *set, size_t n);
387387
mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
@@ -872,5 +872,7 @@ mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t
872872
#define MP_OBJ_IS_STR mp_obj_is_str
873873
#define MP_OBJ_IS_STR_OR_BYTES mp_obj_is_str_or_bytes
874874
#define MP_OBJ_IS_FUN mp_obj_is_fun
875+
#define MP_MAP_SLOT_IS_FILLED mp_map_slot_is_filled
876+
#define MP_SET_SLOT_IS_FILLED mp_set_slot_is_filled
875877

876878
#endif // MICROPY_INCLUDED_PY_OBJ_H

‎py/objdict.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
4343
mp_map_t *map = &dict->map;
4444

4545
for (size_t i = *cur; i < max; i++) {
46-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
46+
if (mp_map_slot_is_filled(map, i)) {
4747
*cur = i + 1;
4848
return &(map->table[i]);
4949
}
@@ -364,7 +364,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
364364

365365
// update the dict with any keyword args
366366
for (size_t i = 0; i < kwargs->alloc; i++) {
367-
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
367+
if (mp_map_slot_is_filled(kwargs, i)) {
368368
mp_map_lookup(&self->map, kwargs->table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = kwargs->table[i].value;
369369
}
370370
}

‎py/objset.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
8585
#endif
8686
mp_print_str(print, "{");
8787
for (size_t i = 0; i < self->set.alloc; i++) {
88-
if (MP_SET_SLOT_IS_FILLED(&self->set, i)) {
88+
if (mp_set_slot_is_filled(&self->set, i)) {
8989
if (!first) {
9090
mp_print_str(print, ", ");
9191
}
@@ -135,7 +135,7 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
135135
mp_set_t *set = &self->set->set;
136136

137137
for (size_t i = self->cur; i < max; i++) {
138-
if (MP_SET_SLOT_IS_FILLED(set, i)) {
138+
if (mp_set_slot_is_filled(set, i)) {
139139
self->cur = i + 1;
140140
return set->table[i];
141141
}
@@ -441,7 +441,7 @@ STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
441441
mp_set_t *set = &self->set;
442442

443443
for (size_t i = 0; i < max; i++) {
444-
if (MP_SET_SLOT_IS_FILLED(set, i)) {
444+
if (mp_set_slot_is_filled(set, i)) {
445445
hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, set->table[i]));
446446
}
447447
}

‎py/objtype.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
594594
mp_map_t *map = &self->members;
595595
mp_obj_t attr_dict = mp_obj_new_dict(map->used);
596596
for (size_t i = 0; i < map->alloc; ++i) {
597-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
597+
if (mp_map_slot_is_filled(map, i)) {
598598
mp_obj_dict_store(attr_dict, map->table[i].key, map->table[i].value);
599599
}
600600
}
@@ -1146,7 +1146,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
11461146
// Check if the class has any special accessor methods
11471147
if (!(o->flags & TYPE_FLAG_HAS_SPECIAL_ACCESSORS)) {
11481148
for (size_t i = 0; i < o->locals_dict->map.alloc; i++) {
1149-
if (MP_MAP_SLOT_IS_FILLED(&o->locals_dict->map, i)) {
1149+
if (mp_map_slot_is_filled(&o->locals_dict->map, i)) {
11501150
const mp_map_elem_t *elem = &o->locals_dict->map.table[i];
11511151
if (check_for_special_accessors(elem->key, elem->value)) {
11521152
o->flags |= TYPE_FLAG_HAS_SPECIAL_ACCESSORS;

‎py/runtime.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_
761761
mp_map_t *map = mp_obj_dict_get_map(kw_dict);
762762
assert(args2_len + 2 * map->used <= args2_alloc); // should have enough, since kw_dict_len is in this case hinted correctly above
763763
for (size_t i = 0; i < map->alloc; i++) {
764-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
764+
if (mp_map_slot_is_filled(map, i)) {
765765
// the key must be a qstr, so intern it if it's a string
766766
mp_obj_t key = map->table[i].key;
767767
if (!mp_obj_is_qstr(key)) {
@@ -1393,7 +1393,7 @@ void mp_import_all(mp_obj_t module) {
13931393
// TODO: Support __all__
13941394
mp_map_t *map = &mp_obj_module_get_globals(module)->map;
13951395
for (size_t i = 0; i < map->alloc; i++) {
1396-
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
1396+
if (mp_map_slot_is_filled(map, i)) {
13971397
// Entry in module global scope may be generated programmatically
13981398
// (and thus be not a qstr for longer names). Avoid turning it in
13991399
// qstr if it has '_' and was used exactly to save memory.

0 commit comments

Comments
 (0)