mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
ircd:Ⓜ️ Split the origins iteration to also allow raw key iteration.
This commit is contained in:
parent
8a5462063e
commit
7a860964c4
2 changed files with 29 additions and 16 deletions
|
@ -251,6 +251,7 @@ struct ircd::m::room::origins
|
|||
|
||||
m::room room;
|
||||
|
||||
bool _test_(const closure_bool &view) const;
|
||||
bool test(const closure_bool &view) const;
|
||||
void for_each(const closure &view) const;
|
||||
size_t count() const;
|
||||
|
|
|
@ -670,6 +670,31 @@ const
|
|||
bool
|
||||
ircd::m::room::origins::test(const closure_bool &view)
|
||||
const
|
||||
{
|
||||
string_view last;
|
||||
char lastbuf[256];
|
||||
return _test_([&last, &lastbuf, &view]
|
||||
(const string_view &key)
|
||||
{
|
||||
const string_view &origin //TODO: XXX
|
||||
{
|
||||
split(key, "@").first
|
||||
};
|
||||
|
||||
if(origin == last)
|
||||
return false;
|
||||
|
||||
if(view(origin))
|
||||
return true;
|
||||
|
||||
last = { lastbuf, copy(lastbuf, origin) };
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::origins::_test_(const closure_bool &view)
|
||||
const
|
||||
{
|
||||
db::index &index
|
||||
{
|
||||
|
@ -681,28 +706,15 @@ const
|
|||
index.begin(room.room_id)
|
||||
};
|
||||
|
||||
string_view last;
|
||||
char lastbuf[256];
|
||||
for(; bool(it); ++it)
|
||||
{
|
||||
const string_view &key{it->first};
|
||||
const string_view &origin_member //TODO: XXX
|
||||
const string_view &key //TODO: XXX
|
||||
{
|
||||
split(key, ":::").second
|
||||
lstrip(it->first, ":::")
|
||||
};
|
||||
|
||||
const string_view &origin //TODO: XXX
|
||||
{
|
||||
split(origin_member, "@").first
|
||||
};
|
||||
|
||||
if(origin == last)
|
||||
continue;
|
||||
|
||||
if(view(origin))
|
||||
if(view(key))
|
||||
return true;
|
||||
|
||||
last = { lastbuf, copy(lastbuf, origin) };
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue