summaryrefslogtreecommitdiff
path: root/py/objtuple.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-02-27 15:32:29 +1100
committerDamien George <damien@micropython.org>2024-03-07 14:20:42 +1100
commitdecf8e6a8bb940d5829ca3296790631fcece7b21 (patch)
tree55b7cd31de14b73e4b72d49344e9084f402767a9 /py/objtuple.c
parentb3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff)
all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit d5df6cd44a433d6253a61cb0f987835fbc06b2de. The original reason for this was to have the option to define it to nothing so that all static functions become global functions and therefore visible to certain debug tools, so one could do function size comparison and other things. This STATIC feature is rarely (if ever) used. And with the use of LTO and heavy inline optimisation, analysing the size of individual functions when they are not static is not a good representation of the size of code when fully optimised. So the macro does not have much use and it's simpler to just remove it. Then you know exactly what it's doing. For example, newcomers don't have to learn what the STATIC macro is and why it exists. Reading the code is also less "loud" with a lowercase static. One other minor point in favour of removing it, is that it stops bugs with `STATIC inline`, which should always be `static inline`. Methodology for this commit was: 1) git ls-files | egrep '\.[ch]$' | \ xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/" 2) Do some manual cleanup in the diff by searching for the word STATIC in comments and changing those back. 3) "git-grep STATIC docs/", manually fixed those cases. 4) "rg -t python STATIC", manually fixed codegen lines that used STATIC. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'py/objtuple.c')
-rw-r--r--py/objtuple.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/py/objtuple.c b/py/objtuple.c
index cb1d7cd38..2cbcc0e50 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -65,7 +65,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
}
}
-STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
(void)type_in;
mp_arg_check_num(n_args, n_kw, 0, 1, false);
@@ -107,7 +107,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
}
// Don't pass MP_BINARY_OP_NOT_EQUAL here
-STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
+static mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
mp_check_self(mp_obj_is_tuple_compatible(self_in));
const mp_obj_type_t *another_type = mp_obj_get_type(another_in);
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
@@ -203,26 +203,26 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
}
}
-STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
+static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
mp_check_self(mp_obj_is_type(self_in, &mp_type_tuple));
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
return mp_seq_count_obj(self->items, self->len, value);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
+static MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
-STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
+static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
mp_check_self(mp_obj_is_type(args[0], &mp_type_tuple));
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]);
return mp_seq_index_obj(self->items, self->len, n_args, args);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
+static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
-STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = {
+static const mp_rom_map_elem_t tuple_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) },
{ MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) },
};
-STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
+static MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_tuple,
@@ -277,7 +277,7 @@ typedef struct _mp_obj_tuple_it_t {
size_t cur;
} mp_obj_tuple_it_t;
-STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
+static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in);
if (self->cur < self->tuple->len) {
mp_obj_t o_out = self->tuple->items[self->cur];