about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/libexpr/nixexpr.hh10
-rw-r--r--third_party/nix/src/libexpr/symbol-table.hh5
2 files changed, 13 insertions, 2 deletions
diff --git a/third_party/nix/src/libexpr/nixexpr.hh b/third_party/nix/src/libexpr/nixexpr.hh
index 3bf9e4a1a77a..4b2bd86ef966 100644
--- a/third_party/nix/src/libexpr/nixexpr.hh
+++ b/third_party/nix/src/libexpr/nixexpr.hh
@@ -3,6 +3,7 @@
 #include <map>
 #include <optional>
 #include <variant>
+#include <absl/container/flat_hash_map.h>
 
 #include "libexpr/symbol-table.hh"
 #include "libexpr/value.hh"
@@ -183,6 +184,7 @@ struct ExprOpHasAttr : Expr {
 
 struct ExprAttrs : Expr {
   bool recursive;
+
   struct AttrDef {
     bool inherited;
     Expr* e;
@@ -192,16 +194,20 @@ struct ExprAttrs : Expr {
         : inherited(inherited), e(e), pos(pos){};
     AttrDef(){};
   };
-  typedef std::map<Symbol, AttrDef> AttrDefs;
+
+  typedef absl::flat_hash_map<Symbol, AttrDef> AttrDefs;
   AttrDefs attrs;
+
   struct DynamicAttrDef {
     Expr *nameExpr, *valueExpr;
     Pos pos;
     DynamicAttrDef(Expr* nameExpr, Expr* valueExpr, const Pos& pos)
         : nameExpr(nameExpr), valueExpr(valueExpr), pos(pos){};
   };
+
   typedef std::vector<DynamicAttrDef> DynamicAttrDefs;
   DynamicAttrDefs dynamicAttrs;
+
   ExprAttrs() : recursive(false){};
   COMMON_METHODS
 };
@@ -336,7 +342,7 @@ struct ExprPos : Expr {
 struct StaticEnv {
   bool isWith;
   const StaticEnv* up;
-  typedef std::map<Symbol, unsigned int> Vars;
+  typedef absl::flat_hash_map<Symbol, unsigned int> Vars;
   Vars vars;
   StaticEnv(bool isWith, const StaticEnv* up) : isWith(isWith), up(up){};
 };
diff --git a/third_party/nix/src/libexpr/symbol-table.hh b/third_party/nix/src/libexpr/symbol-table.hh
index dcb44d32f623..3542f0eadad1 100644
--- a/third_party/nix/src/libexpr/symbol-table.hh
+++ b/third_party/nix/src/libexpr/symbol-table.hh
@@ -26,6 +26,11 @@ class Symbol {
   bool empty() const { return s->empty(); }
 
   friend std::ostream& operator<<(std::ostream& str, const Symbol& sym);
+
+  template <typename H>
+  friend H AbslHashValue(H h, const Symbol& c) {
+    return H::combine(std::move(h), c.s);
+  }
 };
 
 // SymbolTable is a hash-set based symbol-interning mechanism.