0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-26 18:38:52 +02:00

ircd:Ⓜ️:state: Use loop condition rather than exception catch.

This commit is contained in:
Jason Volk 2018-04-11 17:23:01 -07:00
parent 9336b28095
commit 4db39a1bcb

View file

@ -63,12 +63,12 @@ ircd::m::state::get(std::nothrow_t,
const string_view &root,
const json::array &key,
const val_closure &closure)
try
{
bool ret{false};
char nextbuf[ID_MAX_SZ];
string_view nextid{root};
while(nextid) get_node(nextid, [&](const node &node)
const auto node_closure{[&ret, &nextbuf, &nextid, &key, &closure]
(const node &node)
{
auto pos(node.find(key));
if(pos < node.keys() && node.key(pos) == key)
@ -87,14 +87,14 @@ try
nextid = { nextbuf, strlcpy(nextbuf, node.child(pos)) };
else
nextid = {};
});
}};
while(nextid)
if(!get_node(std::nothrow, nextid, node_closure))
return false;
return ret;
}
catch(const db::not_found &e)
{
return false;
}
size_t
ircd::m::state::accumulate(const string_view &root,