about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04T16·03+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04T16·03+0000
commit9b44480612dd30a7292ec94a88e4018b8f18e3f0 (patch)
tree0c83114806a4f7724a5dd8dcb0694103e70acb71 /src/libexpr/nixexpr.cc
parentc4f7ae4aa5fc7071cfa853ec5d75aaf00e7a97fc (diff)
* Use a map to lookup primops.
* Various performance improvements in the evaluator.
* Do not link against unused (and missing!) libraries (-lsglr, etc.).

Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 92027a70ebd7..7739e99a96be 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -20,8 +20,7 @@ ATermMap::ATermMap(const ATermMap & map)
     table = ATtableCreate(ATgetLength(keys), maxLoadPct);
     if (!table) throw Error("cannot create ATerm table");
 
-    for (ATermIterator i(keys); i; ++i)
-        set(*i, map.get(*i));
+    add(map, keys);
 }
 
 
@@ -75,6 +74,26 @@ ATermList ATermMap::keys() const
 }
 
 
+void ATermMap::add(const ATermMap & map)
+{
+    ATermList keys = map.keys();
+    add(map, keys);
+}
+
+
+void ATermMap::add(const ATermMap & map, ATermList & keys)
+{
+    for (ATermIterator i(keys); i; ++i)
+        set(*i, map.get(*i));
+}
+
+
+void ATermMap::reset()
+{
+    ATtableReset(table);
+}
+
+
 ATerm string2ATerm(const string & s)
 {
     return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s.c_str(), 0, ATtrue));