From ac1e8f40d4a5c380d68bb6f1c7cef6f1e7987c1a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 13 Apr 2010 12:25:42 +0000 Subject: * Use a symbol table to represent identifiers and attribute names efficiently. The symbol table ensures that there is only one copy of each symbol, thus allowing symbols to be compared efficiently using a pointer equality test. --- src/libexpr/eval.hh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index cbdd09085d7d..fe91db2efd70 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -4,6 +4,7 @@ #include #include "nixexpr.hh" +#include "symbol-table.hh" namespace nix { @@ -14,9 +15,7 @@ class EvalState; struct Env; struct Value; -typedef string Sym; - -typedef std::map Bindings; +typedef std::map Bindings; struct Env @@ -161,6 +160,10 @@ class EvalState public: DrvHashes drvHashes; /* normalised derivation hashes */ + SymbolTable symbols; + + const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName; + private: SrcToStore srcToStore; @@ -235,6 +238,13 @@ private: void addPrimOp(const string & name, unsigned int arity, PrimOp primOp); + Value * lookupVar(Env * env, const Symbol & name); + + Value * lookupWith(Env * env, const Symbol & name); + + friend class ExprVar; + friend class ExprAttrs; + public: /* Do a deep equality test between two values. That is, list -- cgit 1.4.1