poldek: poldek/pkgdir/pkgdir_dirindex.c - removed duplicate checki...

mis mis at pld-linux.org
Thu Jul 12 22:56:12 CEST 2007


Author: mis                          Date: Thu Jul 12 20:56:12 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- removed duplicate checking - too much sort()s (a lot of)

---- Files affected:
poldek/poldek/pkgdir:
   pkgdir_dirindex.c (1.16 -> 1.17) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgdir/pkgdir_dirindex.c
diff -u poldek/poldek/pkgdir/pkgdir_dirindex.c:1.16 poldek/poldek/pkgdir/pkgdir_dirindex.c:1.17
--- poldek/poldek/pkgdir/pkgdir_dirindex.c:1.16	Mon Jul  2 18:39:22 2007
+++ poldek/poldek/pkgdir/pkgdir_dirindex.c	Thu Jul 12 22:56:07 2007
@@ -542,32 +542,35 @@
 {
     const char **tl, **tl_save;
     char val[16 * 1024];
-    int  vlen, n = 0, nadded = 0, created_here = 0;
+    int  vlen, ndirs = 0;
 
     n_assert(key[1] == PREFIX_PKGKEY_REQDIR);
     vlen = sizeof(val);
-    tl = tl_save = get_package_directories(db, key, klen, val, &vlen, &n);
+    tl = tl_save = get_package_directories(db, key, klen, val, &vlen, &ndirs);
     if (tl == NULL)
         return 0;
     
-    if (!pkg->reqs) {
-        pkg->reqs = capreq_arr_new(n);
-        created_here = 1;
-    }
+    if (pkg->reqs == NULL)
+        pkg->reqs = capreq_arr_new(ndirs);
     
     while (*tl) {
         const char *dir = *tl;
         
-        if (*dir && (created_here || !capreq_arr_contains(pkg->reqs, dir))) {
+        if (*dir) {
             struct capreq *req = capreq_new(pkg->na, dir, 0, NULL, NULL, 0,
                                             CAPREQ_BASTARD);
             n_array_push(pkg->reqs, req);
-            nadded++;
         }
         tl++;
     }
+    
+    if (ndirs > 10)
+        n_array_sort(pkg->reqs);
+    else
+        n_array_isort(pkg->reqs);
+    
     n_str_tokl_free(tl_save);
-    return nadded;
+    return ndirs;
 }
     
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pkgdir_dirindex.c?r1=1.16&r2=1.17&f=u



More information about the pld-cvs-commit mailing list