mirror of
https://github.com/matrix-construct/construct
synced 2024-05-29 00:03:45 +02:00
ircd:Ⓜ️ Add parallel index() overload for event::prev.
This commit is contained in:
parent
00bd72e3ff
commit
5fdc492470
|
@ -16,6 +16,9 @@ namespace ircd::m
|
|||
// Parallel query; returns number of successful results (positions are fixed)
|
||||
size_t index(const vector_view<event::idx> &out, const vector_view<const event::id> &in);
|
||||
|
||||
// Parallel query; returns number of successful results (positions are fixed)
|
||||
size_t index(const vector_view<event::idx> &out, const m::event::prev &);
|
||||
|
||||
// Responds with idx in closure; returns false if no action.
|
||||
bool index(std::nothrow_t, const event::id &, const event::closure_idx &);
|
||||
|
||||
|
|
|
@ -98,6 +98,29 @@ ircd::m::index(std::nothrow_t,
|
|||
});
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::index(const vector_view<event::idx> &out,
|
||||
const event::prev &prev)
|
||||
{
|
||||
const auto num
|
||||
{
|
||||
std::min(prev.prev_events_count(), event::prev::MAX)
|
||||
};
|
||||
|
||||
size_t i(0);
|
||||
event::id event_id[num];
|
||||
m::for_each(prev, [&num, &i, &event_id]
|
||||
(const auto &prev_id)
|
||||
{
|
||||
assert(i < num);
|
||||
event_id[i++] = prev_id;
|
||||
return i < num;
|
||||
});
|
||||
|
||||
assert(i == num);
|
||||
return index(out, vector_view<const event::id>(event_id, i));
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::index(const vector_view<event::idx> &out_,
|
||||
const vector_view<const event::id> &in_)
|
||||
|
|
Loading…
Reference in a new issue