From: Michael Tremer Date: Sat, 11 Jan 2025 14:10:45 +0000 (+0000) Subject: parser: Don't try to expand empty strings X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bb54fc33536eccdf267f4f9829db37c12c99317;p=people%2Fric9%2Fpakfire.git parser: Don't try to expand empty strings This is just a fast path to avoid doing unnecessary work. Signed-off-by: Michael Tremer --- 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)