0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:room::origins: Simplify callstack; remove unused iteration.

This commit is contained in:
Jason Volk 2020-03-09 13:16:08 -07:00
parent f9a6381b8e
commit 3b2342e001
2 changed files with 14 additions and 32 deletions

View file

@ -20,8 +20,6 @@ struct ircd::m::room::origins
using closure = std::function<void (const string_view &)>;
using closure_bool = std::function<bool (const string_view &)>;
static bool _for_each(const origins &, const closure_bool &view);
m::room room;
public:

View file

@ -214,31 +214,6 @@ const
bool
ircd::m::room::origins::for_each(const closure_bool &view)
const
{
string_view last;
char lastbuf[rfc1035::NAME_BUFSIZE];
return _for_each(*this, [&last, &lastbuf, &view]
(const string_view &key)
{
const string_view &origin
{
std::get<0>(dbs::room_joined_key(key))
};
if(origin == last)
return true;
if(!view(origin))
return false;
last = { lastbuf, copy(lastbuf, origin) };
return true;
});
}
bool
ircd::m::room::origins::_for_each(const origins &origins,
const closure_bool &view)
{
db::domain &index
{
@ -247,18 +222,27 @@ ircd::m::room::origins::_for_each(const origins &origins,
auto it
{
index.begin(origins.room.room_id)
index.begin(room.room_id)
};
for(; bool(it); ++it)
char lastbuf[rfc1035::NAME_BUFSIZE];
for(string_view last; bool(it); ++it)
{
const string_view &key
const auto &[origin, user_id]
{
lstrip(it->first, "\0"_sv)
dbs::room_joined_key(it->first)
};
if(!view(key))
if(origin == last)
continue;
if(!view(origin))
return false;
last =
{
lastbuf, copy(lastbuf, origin)
};
}
return true;