From ea0a23645f03a42252ab1ce8df45ae4076ebae75 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 28 Dec 2025 16:23:22 +0100 Subject: teco_string_t is now passed by value like a scalar if the callee isn't expected to modify it * When passing a struct that should not be modified, I usually use a const pointer. * Strings however are small 2-word objects and they are often now already passed via separate `gchar*` and gsize parameters. So it is consistent to pass teco_string_t by value as well. A teco_string_t will usually fit into registers just like a pointer. * It's now obvious which function just _uses_ and which function _modifies_ a string. There is also no chance to pass a NULL pointer to those functions. --- src/core-commands.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core-commands.h') diff --git a/src/core-commands.h b/src/core-commands.h index 425379e..782cb89 100644 --- a/src/core-commands.h +++ b/src/core-commands.h @@ -74,9 +74,9 @@ extern guint teco_ranges_count; extern teco_range_t *teco_ranges; gboolean teco_state_insert_initial(teco_machine_main_t *ctx, GError **error); -gboolean teco_state_insert_process(teco_machine_main_t *ctx, const teco_string_t *str, +gboolean teco_state_insert_process(teco_machine_main_t *ctx, teco_string_t str, gsize new_chars, GError **error); -teco_state_t *teco_state_insert_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error); +teco_state_t *teco_state_insert_done(teco_machine_main_t *ctx, teco_string_t str, GError **error); /* in cmdline.c */ gboolean teco_state_insert_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx, -- cgit v1.2.3