aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/goto-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 22:08:16 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 22:08:16 +0200
commit33bab281e27cf866e77fb3bba6e37f5a5edfef03 (patch)
tree8332298257ccabe511efbc6deeec0de25672fe10 /src/goto-commands.c
parent6aa97a68a85b83267de597bfb30b70c04b7de97b (diff)
Revert "optimize main state machine transitions with tail calls"HEADmaster-fmsbw-cimaster
For yet unknown reasons this does not improve performance on GCC 16 even though it also supports `__attribute__((musttail))`. As long as I do not understand why, I don't want to risk any unnecessary problems. I have reason to believe that the tail-call optimized version still has subtle bugs. See also the "tail-calls" branch. This reverts commit 2e097cec409182c3cb39b74489387480bf8a278f.
Diffstat (limited to 'src/goto-commands.c')
-rw-r--r--src/goto-commands.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/goto-commands.c b/src/goto-commands.c
index 72ac80d..a9ff3c2 100644
--- a/src/goto-commands.c
+++ b/src/goto-commands.c
@@ -61,8 +61,8 @@ teco_state_label_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
{
if (!ctx->goto_label.len) {
switch (chr) {
- case '*': TECO_RETURN(ctx, &teco_state_blockcomment, error); /* `!*` */
- case '!': TECO_RETURN(ctx, &teco_state_eolcomment, error); /* `!!` */
+ case '*': return &teco_state_blockcomment; /* `!*` */
+ case '!': return &teco_state_eolcomment; /* `!!` */
}
}
@@ -97,7 +97,7 @@ teco_state_label_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
teco_string_clear(&ctx->goto_label);
memset(&ctx->goto_label, 0, sizeof(ctx->goto_label));
- TECO_RETURN(ctx, &teco_state_start, error);
+ return &teco_state_start;
}
/*
@@ -109,7 +109,7 @@ teco_state_label_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
if (ctx->parent.must_undo)
undo__teco_string_truncate(&ctx->goto_label, ctx->goto_label.len);
teco_string_append_wc(&ctx->goto_label, chr);
- TECO_RETURN(ctx, &teco_state_label, error);
+ return &teco_state_label;
}
TECO_DEFINE_STATE(teco_state_label,
@@ -244,34 +244,34 @@ TECO_DEFINE_STATE_EXPECTSTRING(teco_state_goto,
)
static teco_state_t *
-teco_state_blockcomment_star_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
+teco_state_blockcomment_star_input(teco_machine_t *ctx, gunichar chr, GError **error)
{
- TECO_RETURN(ctx, chr == '!' ? &teco_state_start : &teco_state_blockcomment, error);
+ return chr == '!' ? &teco_state_start : &teco_state_blockcomment;
}
static TECO_DEFINE_STATE_COMMENT(teco_state_blockcomment_star,
- .input_cb = (teco_state_input_cb_t)teco_state_blockcomment_star_input
+ .input_cb = teco_state_blockcomment_star_input
);
static teco_state_t *
-teco_state_blockcomment_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
+teco_state_blockcomment_input(teco_machine_t *ctx, gunichar chr, GError **error)
{
- TECO_RETURN(ctx, chr == '*' ? &teco_state_blockcomment_star : &teco_state_blockcomment, error);
+ return chr == '*' ? &teco_state_blockcomment_star : &teco_state_blockcomment;
}
static TECO_DEFINE_STATE_COMMENT(teco_state_blockcomment,
- .input_cb = (teco_state_input_cb_t)teco_state_blockcomment_input
+ .input_cb = teco_state_blockcomment_input
);
/*
* `!!` line comments are inspired by TECO-64.
*/
static teco_state_t *
-teco_state_eolcomment_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
+teco_state_eolcomment_input(teco_machine_t *ctx, gunichar chr, GError **error)
{
- TECO_RETURN(ctx, chr == '\n' ? &teco_state_start : &teco_state_eolcomment, error);
+ return chr == '\n' ? &teco_state_start : &teco_state_eolcomment;
}
static TECO_DEFINE_STATE_COMMENT(teco_state_eolcomment,
- .input_cb = (teco_state_input_cb_t)teco_state_eolcomment_input
+ .input_cb = teco_state_eolcomment_input
);