0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 15:04:10 +01:00

ircd:Ⓜ️:user::mitsein: Replace string w/ hash for seen state.

This commit is contained in:
Jason Volk 2020-12-28 18:59:01 -08:00
parent 30d7c11db7
commit ff0a6c2ce7

View file

@ -71,16 +71,11 @@ const
// here we gooooooo :/
///TODO: ideal: db schema
///TODO: minimally: custom alloc?
std::set<std::string, std::less<>> seen;
std::set<uint128_t, std::less<>> seen;
return rooms.for_each(membership, rooms::closure_bool{[&membership, &closure, &seen]
(m::room room, const string_view &)
(const m::room &room, const string_view &_membership)
{
static const event::fetch::opts fopts
{
event::keys::include {"state_key"}
};
room.fopts = &fopts;
assert(_membership == membership);
const m::room::members members
{
room
@ -89,16 +84,20 @@ const
return members.for_each(membership, [&seen, &closure]
(const user::id &other)
{
const auto it
const auto hash
{
seen.lower_bound(other)
uint128_t(ircd::hash(other))
| (uint128_t(ircd::hash(other.host())) << 64)
};
if(it != end(seen) && *it == other)
return true;
const bool inserted
{
seen.emplace(hash).second
};
seen.emplace_hint(it, std::string{other});
return closure(m::user{other});
return inserted?
closure(m::user{other}):
true;
});
}});
}