about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-25T20·27+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-25T20·27+0000
commit2a2756b85643de6355b7b9e3cc47574e7df82303 (patch)
tree1e44145bc88c55f6d70b05503b7741a613b36e3c
parenta9340fa67222bf7ab9057d132af387031b00997d (diff)
* Simplification: registerSubstitutes -> registerSubstitute. We no
  longer need the former since there we no longer have the
  substitutes-rev table (which triggered a O(n^2) cost in updating
  them).

-rw-r--r--src/libstore/build.cc1
-rw-r--r--src/libstore/store.cc25
-rw-r--r--src/libstore/store.hh5
-rw-r--r--src/nix-store/main.cc5
4 files changed, 12 insertions, 24 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 7dd7412e9f21..e5089bdb4515 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -887,7 +887,6 @@ bool DerivationGoal::prepareBuild()
         /* Add the relevant output closures of the input derivation
            `*i' as input paths.  Only add the closures of output paths
            that are specified as inputs. */
-        /* !!! is `*i' present? */
         assert(isValidPath(i->first));
         Derivation inDrv = derivationFromPath(i->first);
         for (StringSet::iterator j = i->second.begin();
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 02bf9803b29c..0dd4e1ed2553 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -331,26 +331,19 @@ static void writeSubstitutes(const Transaction & txn,
 }
 
 
-void registerSubstitutes(const Transaction & txn,
-    const SubstitutePairs & subPairs)
+void registerSubstitute(const Transaction & txn,
+    const Path & srcPath, const Substitute & sub)
 {
-    for (SubstitutePairs::const_iterator i = subPairs.begin();
-         i != subPairs.end(); ++i)
-    {
-        const Path & srcPath(i->first);
-        const Substitute & sub(i->second);
-
-        assertStorePath(srcPath);
+    assertStorePath(srcPath);
     
-        Substitutes subs = readSubstitutes(txn, srcPath);
+    Substitutes subs = readSubstitutes(txn, srcPath);
 
-        /* New substitutes take precedence over old ones.  If the
-           substitute is already present, it's moved to the front. */
-        remove(subs.begin(), subs.end(), sub);
-        subs.push_front(sub);
+    /* New substitutes take precedence over old ones.  If the
+       substitute is already present, it's moved to the front. */
+    remove(subs.begin(), subs.end(), sub);
+    subs.push_front(sub);
         
-        writeSubstitutes(txn, srcPath, subs);
-    }
+    writeSubstitutes(txn, srcPath, subs);
 }
 
 
diff --git a/src/libstore/store.hh b/src/libstore/store.hh
index d59634a830e7..20f50cbfb1c5 100644
--- a/src/libstore/store.hh
+++ b/src/libstore/store.hh
@@ -41,9 +41,8 @@ void createStoreTransaction(Transaction & txn);
 void copyPath(const Path & src, const Path & dst);
 
 /* Register a substitute. */
-typedef list<pair<Path, Substitute> > SubstitutePairs;
-void registerSubstitutes(const Transaction & txn,
-    const SubstitutePairs & subPairs);
+void registerSubstitute(const Transaction & txn,
+    const Path & srcPath, const Substitute & sub);
 
 /* Return the substitutes for the given path. */
 Substitutes querySubstitutes(const Path & srcPath);
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 51e587255003..ed93f2065790 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -170,7 +170,6 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
     if (!opArgs.empty())
         throw UsageError("no arguments expected");
 
-    SubstitutePairs subPairs;
     Transaction txn;
     createStoreTransaction(txn);
 
@@ -196,12 +195,10 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
             references.insert(s);
         }
         if (!cin || cin.eof()) throw Error("missing input");
-        subPairs.push_back(pair<Path, Substitute>(srcPath, sub));
+        registerSubstitute(txn, srcPath, sub);
         setReferences(txn, srcPath, references);
     }
 
-    registerSubstitutes(txn, subPairs);
-    
     txn.commit();
 }