summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstrunicode.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/objstrunicode.c
parentb3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff)
downloadmicropython-decf8e6a8bb940d5829ca3296790631fcece7b21.tar.gz
micropython-decf8e6a8bb940d5829ca3296790631fcece7b21.zip
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/objstrunicode.c')
-rw-r--r--py/objstrunicode.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index cbc797de29..d7ce4fca0e 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -34,12 +34,12 @@
#if MICROPY_PY_BUILTINS_STR_UNICODE
-STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
+static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
/******************************************************************************/
/* str */
-STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
+static void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
// this escapes characters, but it will be very slow to print (calling print many times)
bool has_single_quote = false;
bool has_double_quote = false;
@@ -83,7 +83,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
mp_printf(print, "%c", quote_char);
}
-STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+static void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
GET_STR_DATA_LEN(self_in, str_data, str_len);
#if MICROPY_PY_JSON
if (kind == PRINT_JSON) {
@@ -98,7 +98,7 @@ STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
}
}
-STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+static mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
GET_STR_DATA_LEN(self_in, str_data, str_len);
switch (op) {
case MP_UNARY_OP_BOOL:
@@ -178,7 +178,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
return s;
}
-STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+static mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
const mp_obj_type_t *type = mp_obj_get_type(self_in);
assert(type == &mp_type_str);
GET_STR_DATA_LEN(self_in, self_data, self_len);
@@ -253,7 +253,7 @@ typedef struct _mp_obj_str_it_t {
size_t cur;
} mp_obj_str_it_t;
-STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
+static mp_obj_t str_it_iternext(mp_obj_t self_in) {
mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in);
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
@@ -267,7 +267,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
}
}
-STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
+static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t));
mp_obj_str_it_t *o = (mp_obj_str_it_t *)iter_buf;
o->base.type = &mp_type_polymorph_iter;