aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.h
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/parser.h
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/parser.h')
-rw-r--r--src/parser.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/parser.h b/src/parser.h
index 4ab4d25..98548b1 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -85,7 +85,7 @@ typedef const struct {
*
* Can be NULL if no interactive feedback is required.
*/
- gboolean (*process_cb)(teco_machine_main_t *ctx, const teco_string_t *str,
+ gboolean (*process_cb)(teco_machine_main_t *ctx, teco_string_t str,
gsize new_chars, GError **error);
/**
@@ -93,7 +93,7 @@ typedef const struct {
* Commands that don't give interactive feedback can use this callback
* to perform their main processing.
*/
- teco_state_t *(*done_cb)(teco_machine_main_t *ctx, const teco_string_t *str, GError **error);
+ teco_state_t *(*done_cb)(teco_machine_main_t *ctx, teco_string_t str, GError **error);
} teco_state_expectstring_t;
typedef const struct {
@@ -110,7 +110,7 @@ typedef gboolean (*teco_state_refresh_cb_t)(teco_machine_t *ctx, GError **error)
typedef gboolean (*teco_state_end_of_macro_cb_t)(teco_machine_t *ctx, GError **error);
typedef gboolean (*teco_state_process_edit_cmd_cb_t)(teco_machine_t *ctx, teco_machine_t *parent_ctx,
gunichar key, GError **error);
-typedef gboolean (*teco_state_insert_completion_cb_t)(teco_machine_t *ctx, const teco_string_t *str, GError **error);
+typedef gboolean (*teco_state_insert_completion_cb_t)(teco_machine_t *ctx, teco_string_t str, GError **error);
typedef enum {
TECO_KEYMACRO_MASK_START = (1 << 0),
@@ -599,7 +599,7 @@ gboolean teco_state_expectstring_refresh(teco_machine_main_t *ctx, GError **erro
/* in cmdline.c */
gboolean teco_state_expectstring_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx,
gunichar key, GError **error);
-gboolean teco_state_expectstring_insert_completion(teco_machine_main_t *ctx, const teco_string_t *str,
+gboolean teco_state_expectstring_insert_completion(teco_machine_main_t *ctx, teco_string_t str,
GError **error);
/**
@@ -629,12 +629,12 @@ gboolean teco_state_expectstring_insert_completion(teco_machine_main_t *ctx, con
); \
TECO_ASSERT_SAFE(NAME.expectstring.done_cb != NULL)
-gboolean teco_state_expectfile_process(teco_machine_main_t *ctx, const teco_string_t *str,
+gboolean teco_state_expectfile_process(teco_machine_main_t *ctx, teco_string_t str,
gsize new_chars, GError **error);
/* in cmdline.c */
gboolean teco_state_expectfile_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx, gunichar key, GError **error);
-gboolean teco_state_expectfile_insert_completion(teco_machine_main_t *ctx, const teco_string_t *str, GError **error);
+gboolean teco_state_expectfile_insert_completion(teco_machine_main_t *ctx, teco_string_t str, GError **error);
/**
* @interface TECO_DEFINE_STATE_EXPECTFILE
@@ -653,7 +653,7 @@ gboolean teco_state_expectfile_insert_completion(teco_machine_main_t *ctx, const
/* in cmdline.c */
gboolean teco_state_expectdir_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx, gunichar key, GError **error);
-gboolean teco_state_expectdir_insert_completion(teco_machine_main_t *ctx, const teco_string_t *str, GError **error);
+gboolean teco_state_expectdir_insert_completion(teco_machine_main_t *ctx, teco_string_t str, GError **error);
/**
* @interface TECO_DEFINE_STATE_EXPECTDIR