mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 02:18:53 +02:00
ircd:Ⓜ️ Reorder top() tuple; use strong type template std::get'ers.
This commit is contained in:
parent
7b514deb80
commit
7659ef3acc
5 changed files with 22 additions and 19 deletions
|
@ -36,8 +36,8 @@ namespace ircd::m
|
|||
id::room::buf room_id(const string_view &id_or_alias);
|
||||
|
||||
// [GET] Current Event ID and depth suite (non-locking) (one only)
|
||||
std::tuple<int64_t, id::event::buf> top(std::nothrow_t, const id::room &);
|
||||
std::tuple<int64_t, id::event::buf> top(const id::room &);
|
||||
std::tuple<id::event::buf, int64_t> top(std::nothrow_t, const id::room &);
|
||||
std::tuple<id::event::buf, int64_t> top(const id::room &);
|
||||
|
||||
// [GET] Current Event ID (non-locking) (one only)
|
||||
id::event::buf head(std::nothrow_t, const id::room &);
|
||||
|
|
|
@ -13,30 +13,30 @@
|
|||
int64_t
|
||||
ircd::m::depth(const id::room &room_id)
|
||||
{
|
||||
return std::get<0>(top(room_id));
|
||||
return std::get<int64_t>(top(room_id));
|
||||
}
|
||||
|
||||
int64_t
|
||||
ircd::m::depth(std::nothrow_t,
|
||||
const id::room &room_id)
|
||||
{
|
||||
return std::get<0>(top(std::nothrow, room_id));
|
||||
return std::get<int64_t>(top(std::nothrow, room_id));
|
||||
}
|
||||
|
||||
ircd::m::id::event::buf
|
||||
ircd::m::head(const id::room &room_id)
|
||||
{
|
||||
return std::get<1>(top(room_id));
|
||||
return std::get<event::id::buf>(top(room_id));
|
||||
}
|
||||
|
||||
ircd::m::id::event::buf
|
||||
ircd::m::head(std::nothrow_t,
|
||||
const id::room &room_id)
|
||||
{
|
||||
return std::get<1>(top(std::nothrow, room_id));
|
||||
return std::get<event::id::buf>(top(std::nothrow, room_id));
|
||||
}
|
||||
|
||||
std::tuple<int64_t, ircd::m::id::event::buf>
|
||||
std::tuple<ircd::m::id::event::buf, int64_t>
|
||||
ircd::m::top(const id::room &room_id)
|
||||
{
|
||||
const auto ret
|
||||
|
@ -44,7 +44,7 @@ ircd::m::top(const id::room &room_id)
|
|||
top(std::nothrow, room_id)
|
||||
};
|
||||
|
||||
if(std::get<0>(ret) == -1)
|
||||
if(std::get<int64_t>(ret) == -1)
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"No head for room %s", string_view{room_id}
|
||||
|
@ -53,7 +53,7 @@ ircd::m::top(const id::room &room_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::tuple<int64_t, ircd::m::id::event::buf>
|
||||
std::tuple<ircd::m::id::event::buf, int64_t>
|
||||
ircd::m::top(std::nothrow_t,
|
||||
const id::room &room_id)
|
||||
{
|
||||
|
@ -65,26 +65,29 @@ ircd::m::top(std::nothrow_t,
|
|||
if(!it)
|
||||
return
|
||||
{
|
||||
-1, id::event::buf{}
|
||||
id::event::buf{}, -1
|
||||
};
|
||||
|
||||
const auto &key{it->first};
|
||||
const auto part
|
||||
{
|
||||
dbs::room_events_key(key)
|
||||
dbs::room_events_key(it->first)
|
||||
};
|
||||
|
||||
const int64_t &depth(std::get<0>(part));
|
||||
std::tuple<int64_t, ircd::m::id::event::buf> ret
|
||||
std::tuple<id::event::buf, int64_t> ret
|
||||
{
|
||||
depth, {}
|
||||
id::event::buf{}, depth
|
||||
};
|
||||
|
||||
const event::idx &event_idx
|
||||
{
|
||||
std::get<1>(part)
|
||||
};
|
||||
|
||||
const event::idx &event_idx{std::get<1>(part)};
|
||||
event::fetch::event_id(event_idx, std::nothrow, [&ret]
|
||||
(const event::id &event_id)
|
||||
{
|
||||
std::get<1>(ret) = event_id;
|
||||
std::get<event::id::buf>(ret) = event_id;
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -203,7 +203,7 @@ commit__iov_iov(const room &room,
|
|||
|
||||
int64_t depth;
|
||||
event::id::buf prev_event_id;
|
||||
std::tie(depth, prev_event_id) = m::top(std::nothrow, room.room_id);
|
||||
std::tie(prev_event_id, depth) = m::top(std::nothrow, room.room_id);
|
||||
|
||||
//TODO: X
|
||||
const json::iov::set_if depth_
|
||||
|
|
|
@ -63,7 +63,7 @@ get__make_join(client &client,
|
|||
|
||||
int64_t depth;
|
||||
m::id::event::buf prev_event_id;
|
||||
std::tie(depth, prev_event_id) = m::top(room_id);
|
||||
std::tie(prev_event_id, depth) = m::top(room_id);
|
||||
|
||||
const m::event::fetch evf
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ get__make_leave(client &client,
|
|||
|
||||
int64_t depth;
|
||||
m::id::event::buf prev_event_id;
|
||||
std::tie(depth, prev_event_id) = m::top(room_id);
|
||||
std::tie(prev_event_id, depth) = m::top(room_id);
|
||||
|
||||
const m::event::fetch evf
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue