From 9af10b753c8a636f828b148fc3a9aecd1c0067fa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Feb 2020 17:15:05 +0100 Subject: Bindings::get(): std::optional -> Attr * Returning a nullable type in an optional is silly. --- src/libexpr/attr-set.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libexpr/attr-set.hh') 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 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]; } -- cgit v1.2.3