aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/help.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2025-12-28 16:23:22 +0100
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2025-12-28 20:57:31 +0100
commitea0a23645f03a42252ab1ce8df45ae4076ebae75 (patch)
tree5fe606a9b07f2f7039b1839f9fac6bab2d212c13 /src/help.c
parentd94521fb5b5a5c3a6315c425dba5f1218f0dd323 (diff)
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.
Diffstat (limited to 'src/help.c')
-rw-r--r--src/help.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/help.c b/src/help.c
index 74b9ecb..9b8273f 100644
--- a/src/help.c
+++ b/src/help.c
@@ -271,7 +271,7 @@ teco_state_help_initial(teco_machine_main_t *ctx, GError **error)
}
static teco_state_t *
-teco_state_help_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error)
+teco_state_help_done(teco_machine_main_t *ctx, teco_string_t str, GError **error)
{
if (ctx->flags.mode > TECO_MODE_NORMAL)
return &teco_state_start;
@@ -281,7 +281,7 @@ teco_state_help_done(teco_machine_main_t *ctx, const teco_string_t *str, GError
"Help topic must not contain null-byte");
return NULL;
}
- const gchar *topic_name = str->data ? : "";
+ const gchar *topic_name = str.data ? : "";
teco_help_topic_t *topic = teco_help_find(topic_name);
if (!topic) {
g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
@@ -316,7 +316,7 @@ teco_state_help_done(teco_machine_main_t *ctx, const teco_string_t *str, GError
/* in cmdline.c */
gboolean teco_state_help_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx,
gunichar chr, GError **error);
-gboolean teco_state_help_insert_completion(teco_machine_main_t *ctx, const teco_string_t *str,
+gboolean teco_state_help_insert_completion(teco_machine_main_t *ctx, teco_string_t str,
GError **error);
/*$ "?" help