0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +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 :/ // here we gooooooo :/
///TODO: ideal: db schema ///TODO: ideal: db schema
///TODO: minimally: custom alloc? ///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] 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 assert(_membership == membership);
{
event::keys::include {"state_key"}
};
room.fopts = &fopts;
const m::room::members members const m::room::members members
{ {
room room
@ -89,16 +84,20 @@ const
return members.for_each(membership, [&seen, &closure] return members.for_each(membership, [&seen, &closure]
(const user::id &other) (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) const bool inserted
return true; {
seen.emplace(hash).second
};
seen.emplace_hint(it, std::string{other}); return inserted?
return closure(m::user{other}); closure(m::user{other}):
true;
}); });
}}); }});
} }