From 1eb4da156cca1b1981ab1f60bb9797ed1e93101a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2003 13:22:29 +0000 Subject: [PATCH] * Performance improvement: don't register already registered terms, thus greatly reducing the number of db transactions. --- src/expr.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/expr.cc b/src/expr.cc index 2ed3e678b..521dffc9c 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; }