about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-22T00·54+0100
committerVincent Ambo <tazjin@google.com>2020-05-22T00·59+0100
commit42205f27fc820ddc64616d55c04e2ffde1948043 (patch)
tree06cbc1332eec9fb083f7a31bf0dcd092d1e23139 /third_party
parentee4637e3a22a1efc480bb66ea025afd107d1b158 (diff)
refactor(3p/nix/libexpr): Use absl::btree_map::iterator type r/801
Instead of using a custom Args* iterator, use the one belonging to the
map type directly.
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/src/libexpr/attr-path.cc2
-rw-r--r--third_party/nix/src/libexpr/attr-set.cc11
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh3
3 files changed, 11 insertions, 5 deletions
diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc
index 3a467504aa..1815b5e510 100644
--- a/third_party/nix/src/libexpr/attr-path.cc
+++ b/third_party/nix/src/libexpr/attr-path.cc
@@ -81,7 +81,7 @@ Value* findAlongAttrPath(EvalState& state, const std::string& attrPath,
             format("attribute '%1%' in selection path '%2%' not found") % attr %
             attrPath);
       }
-      v = &*a->value;
+      v = &*(a->second).value;
     }
 
     else if (apType == apIndex) {
diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc
index e0fac9234b..2df6bc9a21 100644
--- a/third_party/nix/src/libexpr/attr-set.cc
+++ b/third_party/nix/src/libexpr/attr-set.cc
@@ -31,12 +31,17 @@ std::vector<const Attr*> Bindings::lexicographicOrder() {
 }
 
 Bindings::iterator Bindings::find(const Symbol& name) {
-  return &attributes_[name];
+  return attributes_.find(name);
 }
 
-Bindings::iterator Bindings::begin() { return &(attributes_.begin()->second); }
+Bindings::iterator Bindings::begin() {
+  return attributes_.begin();
+}
+
+Bindings::iterator Bindings::end() {
+  return attributes_.end();
+}
 
-Bindings::iterator Bindings::end() { return &(attributes_.end()->second); }
 void Bindings::merge(Bindings* other) {
   // We want the values from the other attribute set to take
   // precedence, but .merge() works the other way around.
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index 39af7c482e..4ae908964c 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -31,7 +31,7 @@ inline bool operator==(const Attr& lhs, const Attr& rhs) {
 
 class Bindings {
  public:
-  typedef Attr* iterator;  // TODO: type, and also 'using'?
+  typedef absl::btree_map<Symbol, Attr>::iterator iterator;
 
   // Return the number of contained elements.
   size_t size();
@@ -71,4 +71,5 @@ class Bindings {
  private:
   absl::btree_map<Symbol, Attr> attributes_;
 };
+
 }  // namespace nix