Bindings::get(): std::optional<Attr *> -> Attr *

Returning a nullable type in an optional is silly.
This commit is contained in:
Eelco Dolstra 2020-02-13 17:15:05 +01:00
parent d8972317fc
commit 9af10b753c

View file

@ -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]; }