summaryrefslogtreecommitdiff
path: root/rpmdb/rpmdb.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-04-07 19:52:42 +0000
committerjbj <devnull@localhost>2002-04-07 19:52:42 +0000
commitffdfd1056e25d18f95776fbff43fceca864be95f (patch)
tree56e72d723560122b38d8a2eb3a00e147ae0440e0 /rpmdb/rpmdb.c
parent6e2d56377d4ac91f44918e58918d777540f6565c (diff)
downloadrpm-ffdfd1056e25d18f95776fbff43fceca864be95f.tar.gz
rpm-ffdfd1056e25d18f95776fbff43fceca864be95f.tar.bz2
rpm-ffdfd1056e25d18f95776fbff43fceca864be95f.zip
- speedup large queries by ~50%.
- revert to presentation ordering Yet Again (#62158). - non-glibc: on upgrade, mergesort is much faster than quicksort. CVS patchset: 5377 CVS date: 2002/04/07 19:52:42
Diffstat (limited to 'rpmdb/rpmdb.c')
-rw-r--r--rpmdb/rpmdb.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 9c4c20f9c..3a6c19c73 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -730,11 +730,6 @@ static INLINE int dbiAppendSet(dbiIndexSet set, const void * recs,
if (set == NULL || recs == NULL || nrecs <= 0 || recsize == 0)
return 1;
-#ifdef DYING
- if (set->count == 0)
- set->recs = xmalloc(nrecs * sizeof(*(set->recs)));
- else
-#endif
set->recs = xrealloc(set->recs,
(set->count + nrecs) * sizeof(*(set->recs)));
@@ -1709,7 +1704,8 @@ int rpmdbGetIteratorCount(rpmdbMatchIterator mi) {
/**
* Return pattern match.
- * @param mi rpm database iterator
+ * @param mire match iterator regex
+ * @param val value to match
* @return 0 if pattern matches
*/
static int miregexec(miRE mire, const char * val)
@@ -2236,8 +2232,17 @@ static void rpmdbSortIterator(/*@null@*/ rpmdbMatchIterator mi)
/*@modifies mi @*/
{
if (mi && mi->mi_set && mi->mi_set->recs && mi->mi_set->count > 0) {
- qsort(mi->mi_set->recs, mi->mi_set->count, sizeof(*mi->mi_set->recs),
- hdrNumCmp);
+ /*
+ * mergesort is much (~10x with lots of identical basenames) faster
+ * than pure quicksort, but glibc uses msort_with_tmp() on stack.
+ */
+#if defined(__GLIBC__)
+ qsort(mi->mi_set->recs, mi->mi_set->count,
+ sizeof(*mi->mi_set->recs), hdrNumCmp);
+#else
+ mergesort(mi->mi_set->recs, mi->mi_set->count,
+ sizeof(*mi->mi_set->recs), hdrNumCmp);
+#endif
mi->mi_sorted = 1;
}
}