summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--razor.c29
2 files changed, 12 insertions, 20 deletions
diff --git a/TODO b/TODO
index e428f89..f1142e5 100644
--- a/TODO
+++ b/TODO
@@ -56,9 +56,6 @@ Misc ideas:
- transactions, proper recovery, make sure we don't poop our package
database (no more rm /var/lib/rpm/__cache*).
-- rewrite qsort and bsearch that doesn't require global context var
- and can output a map describing the permutaion.
-
- use hash table for package and property lists so we only store
unique lists (like for string pool).
diff --git a/razor.c b/razor.c
index 95cd1bf..d50adbc 100644
--- a/razor.c
+++ b/razor.c
@@ -975,26 +975,21 @@ razor_package_iterator_destroy(struct razor_package_iterator *pi)
free(pi);
}
-struct razor_set *bsearch_set;
-
-static int
-compare_package_name(const void *key, const void *data)
-{
- const struct razor_package *p = data;
- char *pool;
-
- pool = bsearch_set->string_pool.data;
-
- return strcmp(key, &pool[p->name]);
-}
-
struct razor_package *
razor_set_get_package(struct razor_set *set, const char *package)
{
- bsearch_set = set;
- return bsearch(package, set->packages.data,
- set->packages.size / sizeof(struct razor_package),
- sizeof(struct razor_package), compare_package_name);
+ struct razor_package_iterator *pi;
+ struct razor_package *p;
+ const char *name, *version;
+
+ pi = razor_package_iterator_create(set);
+ while (razor_package_iterator_next(pi, &p, &name, &version)) {
+ if (strcmp(package, name) == 0)
+ break;
+ }
+ razor_package_iterator_destroy(pi);
+
+ return p;
}
struct razor_property_iterator {