about summary refs log tree commit diff
path: root/src/expr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-10-10T13·22+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-10-10T13·22+0000
commit1eb4da156cca1b1981ab1f60bb9797ed1e93101a (patch)
tree9a06beed80ae344b3cca78660462a7447acf26f2 /src/expr.cc
parent08b7319f5bca01f46916faaec0f9de420404a5ad (diff)
* Performance improvement: don't register already registered terms,
  thus greatly reducing the number of db transactions.

Diffstat (limited to 'src/expr.cc')
-rw-r--r--src/expr.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/expr.cc b/src/expr.cc
index 2ed3e678b39f..521dffc9c693 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -37,12 +37,15 @@ Path writeTerm(ATerm t, const string & suffix)
 
     Path path = canonPath(nixStore + "/" + 
         (string) h + suffix + ".nix");
-    if (!ATwriteToNamedTextFile(t, path.c_str()))
-        throw Error(format("cannot write aterm %1%") % path);
 
-    Transaction txn(nixDB);
-    registerValidPath(txn, path);
-    txn.commit();
+    if (!isValidPath(path)) {
+        if (!ATwriteToNamedTextFile(t, path.c_str()))
+            throw Error(format("cannot write aterm %1%") % path);
+
+        Transaction txn(nixDB);
+        registerValidPath(txn, path);
+        txn.commit();
+    }
 
     return path;
 }