From 8d1f1e4ada152ef26c47c5ba6e5b36fe2eec8551 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Thu, 20 Nov 2025 21:31:08 +0100 Subject: [PATCH] Simplify loading code Turns out past me allowed a subfunction to not have a matcher at all, in which case everything is matched. This is exactly what we want to happen for a apfl_load()ed function, so we don't needt to construct a matcher here at all and can keep things a bit simpler. Nice :) --- src/context.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/context.c b/src/context.c index 76ef73c..c9e4032 100644 --- a/src/context.c +++ b/src/context.c @@ -2358,38 +2358,8 @@ setup_function_for_load_inner(apfl_ctx ctx, struct apfl_string *filename) return NULL; } - struct matcher_instruction_list *milist = apfl_matcher_instructions_new(&ctx->gc); - if ( - milist == NULL - || !apfl_gc_tmproot_add(&ctx->gc, GC_OBJECT_FROM(milist, GC_TYPE_MATCHER_INSTRUCTIONS)) - ) { - return NULL; - } - if (!apfl_resizable_append( - ctx->gc.allocator, - sizeof(union matcher_instruction_or_arg), - (void **)&milist->instructions, - &milist->len, - &milist->cap, - &(union matcher_instruction_or_arg[]) { - {.instruction = MATCHER_IGNORE}, - }, - 1 - )) { - return NULL; - } - - struct matcher *matcher = apfl_matcher_new(&ctx->gc, milist); - if ( - matcher == NULL - || !apfl_gc_tmproot_add(&ctx->gc, GC_OBJECT_FROM(matcher, GC_TYPE_MATCHER)) - ) { - apfl_drop(ctx, -1); - return NULL; - } - - if (!apfl_func_add_subfunc(func_value->func, ilist, matcher)) { + if (!apfl_func_add_subfunc(func_value->func, ilist, NULL)) { apfl_drop(ctx, -1); return NULL; }