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

ircd:Ⓜ️ Parallel event::idx convenience for event::auth; simplify definitions.

This commit is contained in:
Jason Volk 2020-12-18 21:09:47 -08:00
parent 237992b9ed
commit 6c71ec39b2
4 changed files with 32 additions and 38 deletions

View file

@ -56,20 +56,9 @@ inline ircd::vector_view<ircd::m::event::idx>
ircd::m::event::auth::idxs(event::idx (&out)[N])
const
{
event::id buf[N];
const auto &ids
{
auth::ids(buf)
};
const auto &found
{
m::index(out, ids)
};
return vector_view<event::idx>
(
out, out + ids.size()
out, m::index(out, *this)
);
}

View file

@ -16,8 +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)
// Parallel query; returns number number of ids. Successful results non-zero.
size_t index(const vector_view<event::idx> &out, const m::event::prev &);
size_t index(const vector_view<event::idx> &out, const m::event::auth &);
// Responds with idx in closure; returns false if no action.
bool index(std::nothrow_t, const event::id &, const event::closure_idx &);

View file

@ -63,20 +63,9 @@ inline ircd::vector_view<ircd::m::event::idx>
ircd::m::event::prev::idxs(event::idx (&out)[N])
const
{
event::id buf[N];
const auto &ids
{
prev::ids(buf)
};
const auto &found
{
m::index(out, ids)
};
return vector_view<event::idx>
(
out, out + ids.size()
out, m::index(out, *this)
);
}

View file

@ -100,25 +100,40 @@ ircd::m::index(std::nothrow_t,
size_t
ircd::m::index(const vector_view<event::idx> &out,
const event::prev &prev)
const event::auth &auth)
{
const auto num
event::id ids[event::auth::MAX];
const auto &event_ids
{
std::min(prev.prev_events_count(), event::prev::MAX)
auth.ids(ids)
};
size_t i(0);
event::id event_id[num];
m::for_each(prev, [&num, &i, &event_id]
(const auto &prev_id)
const auto &found
{
assert(i < num);
event_id[i++] = prev_id;
return i < num;
});
index(out, event_ids)
};
assert(i == num);
return index(out, vector_view<const event::id>(event_id, i));
assert(found <= event_ids.size());
return event_ids.size();
}
size_t
ircd::m::index(const vector_view<event::idx> &out,
const event::prev &prev)
{
event::id ids[event::prev::MAX];
const auto &event_ids
{
prev.ids(ids)
};
const auto &found
{
index(out, event_ids)
};
assert(found <= event_ids.size());
return event_ids.size();
}
size_t