Bindings::get(): std::optional<Attr *> -> Attr *
Returning a nullable type in an optional is silly.
This commit is contained in:
parent
d8972317fc
commit
9af10b753c
|
@ -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]; }
|
||||
|
|
Loading…
Reference in a new issue