From: Michael Tremer Date: Wed, 3 Mar 2021 11:47:01 +0000 (+0000) Subject: parser: expand: Tidy up some code X-Git-Tag: 0.9.28~1285^2~655 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a29317d3a4da55dc0e802d072a97ff0da788769b;p=pakfire.git parser: expand: Tidy up some code No functional changes Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index cceaed924..a8a238e5d 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -340,9 +340,13 @@ PAKFIRE_EXPORT char* pakfire_parser_expand(PakfireParser parser, if (!value) return NULL; + // Create a working copy of the string we are expanding + char* buffer = strdup(value); + + // Fast path to check if there are any variables in here whatsoever char* pos = strchr(value, '%'); if (!pos) - return strdup(value); + return buffer; // Compile the regular expression regex_t preg; @@ -357,9 +361,6 @@ PAKFIRE_EXPORT char* pakfire_parser_expand(PakfireParser parser, return NULL; } - // Create a working copy of the string we are expanding - char* buffer = strdup(value); - char* variable = NULL; char* pattern = NULL; const size_t max_groups = 2;