aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-02-13 17:15:05 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-02-13 17:15:05 +0100
commit9af10b753c8a636f828b148fc3a9aecd1c0067fa (patch)
tree1ebfeb34a00591cabb2d2c57d12eea36fae9d9d0
parentd8972317fc4314864619cadd5620ae780da657a3 (diff)
Bindings::get(): std::optional<Attr *> -> Attr *
Returning a nullable type in an optional is silly.
-rw-r--r--src/libexpr/attr-set.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index d6af99912..118c7bd5d 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -64,12 +64,12 @@ public:
return end();
}
- std::optional<Attr *> get(const Symbol & name)
+ Attr * get(const Symbol & name)
{
Attr key(name, 0);
iterator i = std::lower_bound(begin(), end(), key);
if (i != end() && i->name == name) return &*i;
- return {};
+ return nullptr;
}
Attr & need(const Symbol & name, const Pos & pos = noPos)
@@ -77,7 +77,7 @@ public:
auto a = get(name);
if (!a)
throw Error("attribute '%s' missing, at %s", name, pos);
- return **a;
+ return *a;
}
iterator begin() { return &attrs[0]; }