mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd:Ⓜ️:room::stats: Optimize byte counter with pipelined iteration.
This commit is contained in:
parent
2060fb2993
commit
5856c2fd0e
1 changed files with 8 additions and 17 deletions
|
@ -32,25 +32,16 @@ size_t
|
||||||
ircd::m::room::stats::bytes_json(const m::room &room)
|
ircd::m::room::stats::bytes_json(const m::room &room)
|
||||||
{
|
{
|
||||||
size_t ret(0);
|
size_t ret(0);
|
||||||
for(m::room::events it(room); it; --it)
|
const room::iterate iterate
|
||||||
{
|
{
|
||||||
const m::event::idx &event_idx
|
room
|
||||||
{
|
};
|
||||||
it.event_idx()
|
|
||||||
};
|
|
||||||
|
|
||||||
const byte_view<string_view> key
|
iterate.for_each([&ret]
|
||||||
{
|
(const string_view &event, const auto &depth, const auto &event_idx)
|
||||||
event_idx
|
{
|
||||||
};
|
ret += size(event);
|
||||||
|
});
|
||||||
static const db::gopts gopts
|
|
||||||
{
|
|
||||||
.cache = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
ret += db::bytes_value(m::dbs::event_json, key, gopts);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue