]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Skip expansion when possible
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jun 2019 13:35:16 +0000 (14:35 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jun 2019 13:35:16 +0000 (14:35 +0100)
This will spare us going through a lot of code when there
is no variable in a string

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index c0bc5182ec9c3a146e52d859e1def4abe9fc0c65..617d49e64802a894b0b18655c20a3e677007604e 100644 (file)
@@ -312,6 +312,10 @@ PAKFIRE_EXPORT char* pakfire_parser_expand(PakfireParser parser, const char* val
        if (!value)
                return NULL;
 
+       char* pos = strchr(value, '%');
+       if (!pos)
+               return pakfire_strdup(value);
+
        // Compile the regular expression
        regex_t preg;
        int r = regcomp(&preg, VARIABLE_PATTERN, REG_EXTENDED);