]> git.ipfire.org Git - pakfire.git/commitdiff
deps: Make the pool for version comparisons persistent
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2025 12:28:48 +0000 (12:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2025 12:28:48 +0000 (12:28 +0000)
This should perform better on the build service when we are sorting
packages, etc. since we can re-use the pool/string pool and
serialization.

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

index b001eb73e534933366ada034e1c5984765658b83..cf81ac99296310973e7c27235d04027012b7cde4 100644 (file)
@@ -64,24 +64,23 @@ static const struct pakfire_rich_operation {
        This function can compare package versions without a Pakfire instance initialized.
 */
 int pakfire_static_version_compare(const char* evr1, const char* evr2) {
-       Pool* pool = NULL;
+       static Pool* pool = NULL;
        int r;
 
        // Initialize the pool
-       pool = pool_create();
-       if (!pool)
-               return 0;
-
-       // Set to RPM mode
-       pool_setdisttype(pool, DISTTYPE_RPM);
+       if (!pool) {
+               printf("GOT HERE\n");
 
-       // Perform comparison
-       r = pool_evrcmp_str(pool, evr1, evr2, EVRCMP_COMPARE);
+               pool = pool_create();
+               if (!pool)
+                       return 0;
 
-       // Free the pool
-       pool_free(pool);
+               // Set to RPM mode
+               pool_setdisttype(pool, DISTTYPE_RPM);
+       }
 
-       return r;
+       // Perform comparison
+       return pool_evrcmp_str(pool, evr1, evr2, EVRCMP_COMPARE);
 }
 
 const char* pakfire_dep2str(struct pakfire* pakfire, Id id) {