aboutsummaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2018-08-05 23:56:19 +0300
committerDamien George <damien.p.george@gmail.com>2018-10-22 22:49:05 +1100
commit5a91fce9f868eeba37a0b1cf6c3b4435ed5eecec (patch)
treea81202c0b0a5d6d68790ea0a42fdb1ee395f6794 /py/objstr.c
parent7795b2e5c3e3dfeb20aaca751c45b4dfceedcc7f (diff)
py/objstr: Make str.count() method configurable.
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled. Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling it saves 408 bytes on x86.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/objstr.c b/py/objstr.c
index e519a9879..1b12147fd 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -1697,6 +1697,7 @@ STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
+#if MICROPY_PY_BUILTINS_STR_COUNT
STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0]));
@@ -1737,6 +1738,7 @@ STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
return MP_OBJ_NEW_SMALL_INT(num_occurrences);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count);
+#endif
#if MICROPY_PY_BUILTINS_STR_PARTITION
STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
@@ -1947,7 +1949,9 @@ STATIC const mp_rom_map_elem_t str8_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_rstrip), MP_ROM_PTR(&str_rstrip_obj) },
{ MP_ROM_QSTR(MP_QSTR_format), MP_ROM_PTR(&str_format_obj) },
{ MP_ROM_QSTR(MP_QSTR_replace), MP_ROM_PTR(&str_replace_obj) },
+ #if MICROPY_PY_BUILTINS_STR_COUNT
{ MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&str_count_obj) },
+ #endif
#if MICROPY_PY_BUILTINS_STR_PARTITION
{ MP_ROM_QSTR(MP_QSTR_partition), MP_ROM_PTR(&str_partition_obj) },
{ MP_ROM_QSTR(MP_QSTR_rpartition), MP_ROM_PTR(&str_rpartition_obj) },