0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd:Ⓜ️:room::type: Add directional iteration deduced by range.

This commit is contained in:
Jason Volk 2022-08-15 17:19:48 -07:00
parent 206afc25b0
commit a8b5912e98

View file

@ -59,10 +59,15 @@ bool
ircd::m::room::type::for_each(const closure &closure)
const
{
const bool desc
{
range.second < 0 || uint64_t(range.second) < range.first
};
char buf[dbs::ROOM_TYPE_KEY_MAX_SIZE];
const string_view &key
{
dbs::room_type_key(buf, room.room_id, _type, range.first, -1UL)
dbs::room_type_key(buf, room.room_id, _type, range.first, desc? -1UL: 0UL)
};
auto it
@ -70,14 +75,17 @@ const
dbs::room_type.begin(key)
};
for(; it; ++it)
for(; it; desc? ++it: --it)
{
const auto &[_type, depth, event_idx]
{
dbs::room_type_key(it->first)
};
if(int64_t(depth) <= range.second)
if(desc && int64_t(depth) <= range.second)
break;
if(!desc && int64_t(depth) >= range.second)
break;
if(this->_type && !prefixing && this->_type != _type)