From 5bb54fc33536eccdf267f4f9829db37c12c99317 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 11 Jan 2025 14:10:45 +0000 Subject: [PATCH] parser: Don't try to expand empty strings This is just a fast path to avoid doing unnecessary work. Signed-off-by: Michael Tremer --- src/pakfire/parser.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pakfire/parser.c b/src/pakfire/parser.c index a4984569a..5244de475 100644 --- a/src/pakfire/parser.c +++ b/src/pakfire/parser.c @@ -599,10 +599,6 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser, if (!buffer) return -EINVAL; - // There is nothing to expend on empty strings - else if (!*buffer) - return 0; - // Compile the regular expression if (!regexes.variable) { r = pakfire_compile_regex(parser->ctx, ®exes.variable, "%\\{([A-Za-z0-9_\\-]+)\\}"); @@ -715,6 +711,10 @@ char* pakfire_parser_expand(struct pakfire_parser* parser, if (!buffer) goto ERROR; + // There is nothing to do for empty strings + if (!*buffer) + return buffer; + // Fast path to check if there are any variables in here whatsoever char* pos = strchr(buffer, '%'); if (!pos) -- 2.47.3