0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-26 18:38:52 +02:00

ircd:Ⓜ️:event::horizon: Split the full column iteration into separate function.

This commit is contained in:
Jason Volk 2019-06-04 21:21:21 -07:00
parent 5e549261fc
commit 475ee3867d
2 changed files with 30 additions and 25 deletions

View file

@ -29,6 +29,7 @@ class ircd::m::event::horizon
public:
using closure_bool = std::function<bool (const event::id &, const event::idx &)>;
static bool for_every(const closure_bool &);
bool for_each(const closure_bool &) const;
bool has(const event::idx &) const;
size_t count() const;

View file

@ -2628,31 +2628,7 @@ ircd::m::event::horizon::for_each(const closure_bool &closure)
const
{
if(!this->event_id)
{
db::column &column{dbs::event_horizon};
for(auto it(column.begin()); it; ++it)
{
const auto &parts
{
split(it->first, "\0"_sv)
};
const auto &event_id
{
parts.first
};
const auto &event_idx
{
byte_view<event::idx>(parts.second)
};
if(!closure(event_id, event_idx))
return false;
}
return true;
}
return for_every(closure);
char buf[m::dbs::EVENT_HORIZON_KEY_MAX_SIZE];
const string_view &key
@ -2674,6 +2650,34 @@ const
return true;
}
bool
ircd::m::event::horizon::for_every(const closure_bool &closure)
{
db::column &column{dbs::event_horizon};
for(auto it(column.begin()); it; ++it)
{
const auto &parts
{
split(it->first, "\0"_sv)
};
const auto &event_id
{
parts.first
};
const auto &event_idx
{
byte_view<event::idx>(parts.second)
};
if(!closure(event_id, event_idx))
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
//
// event/refs.h