From 33bab281e27cf866e77fb3bba6e37f5a5edfef03 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 23 Aug 2026 22:08:16 +0200 Subject: Revert "optimize main state machine transitions with tail calls" 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. --- src/goto-commands.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/goto-commands.c') 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 ); -- cgit v1.2.3