diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-10-10T13·22+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-10-10T13·22+0000 |
commit | 1eb4da156cca1b1981ab1f60bb9797ed1e93101a (patch) | |
tree | 9a06beed80ae344b3cca78660462a7447acf26f2 /src | |
parent | 08b7319f5bca01f46916faaec0f9de420404a5ad (diff) |
* Performance improvement: don't register already registered terms,
thus greatly reducing the number of db transactions.
Diffstat (limited to '')
-rw-r--r-- | src/expr.cc | 13 |
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; } |