Avoid netshared path matching when netshared path is not set
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 3 Sep 2012 12:03:12 +0000 (15:03 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 3 Sep 2012 12:13:08 +0000 (15:13 +0300)
- We've been calling matchNetsharedpath() for every single file in
  the transaction regardless of whether %{_netsharedpath} is set or
  not (and almost always it is not), meaning lots of pointless
  strlen() calls and in case of erasure, rpmfi iterations performed.
  Not exactly a massive speedup but a speedup nevertheless.

lib/transaction.c

index 8f4ccb6..8d2527d 100644 (file)
@@ -699,12 +699,14 @@ static void skipEraseFiles(const rpmts ts, rpmte p)
      * Net shared paths are not relative to the current root (though
      * they do need to take package relocations into account).
      */
-    fi = rpmfiInit(fi, 0);
-    while ((i = rpmfiNext(fi)) >= 0)
-    {
-       nsp = matchNetsharedpath(ts, fi);
-       if (nsp && *nsp) {
-           rpmfsSetAction(fs, i, FA_SKIPNETSHARED);
+    if (ts->netsharedPaths) {
+       fi = rpmfiInit(fi, 0);
+       while ((i = rpmfiNext(fi)) >= 0)
+       {
+           nsp = matchNetsharedpath(ts, fi);
+           if (nsp && *nsp) {
+               rpmfsSetAction(fs, i, FA_SKIPNETSHARED);
+           }
        }
     }
 }
@@ -763,11 +765,13 @@ static void skipInstallFiles(const rpmts ts, rpmte p)
         * Net shared paths are not relative to the current root (though
         * they do need to take package relocations into account).
         */
-       nsp = matchNetsharedpath(ts, fi);
-       if (nsp && *nsp) {
-           drc[ix]--;  dff[ix] = 1;
-           rpmfsSetAction(fs, i, FA_SKIPNETSHARED);
-           continue;
+       if (ts->netsharedPaths) {
+           nsp = matchNetsharedpath(ts, fi);
+           if (nsp && *nsp) {
+               drc[ix]--;      dff[ix] = 1;
+               rpmfsSetAction(fs, i, FA_SKIPNETSHARED);
+               continue;
+           }
        }
 
        /*