Skip to content

Commit

Permalink
Bindings::get(): std::optional<Attr *> -> Attr *
Browse files Browse the repository at this point in the history
Returning a nullable type in an optional is silly.
  • Loading branch information
edolstra committed Feb 13, 2020
1 parent d897231 commit 9af10b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libexpr/attr-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ 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)
{
auto a = get(name);
if (!a)
throw Error("attribute '%s' missing, at %s", name, pos);
return **a;
return *a;
}

iterator begin() { return &attrs[0]; }
Expand Down

0 comments on commit 9af10b7

Please sign in to comment.