0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd:Ⓜ️ Fix event_id() interface for consistent leading std::nothrow_t.

This commit is contained in:
Jason Volk 2020-04-01 15:42:33 -07:00
parent 88987b0e85
commit 93665cc587
17 changed files with 41 additions and 38 deletions

View file

@ -17,11 +17,11 @@
namespace ircd::m namespace ircd::m
{ {
bool event_id(const event::idx &, std::nothrow_t, const event::id::closure &); bool event_id(std::nothrow_t, const event::idx &, const event::id::closure &);
event::id event_id(const event::idx &, event::id::buf &, std::nothrow_t); event::id event_id(std::nothrow_t, const event::idx &, event::id::buf &);
event::id event_id(const event::idx &, event::id::buf &); event::id event_id(const event::idx &, event::id::buf &);
event::id::buf event_id(const event::idx &, std::nothrow_t); event::id::buf event_id(std::nothrow_t, const event::idx &);
event::id::buf event_id(const event::idx &); event::id::buf event_id(const event::idx &);
} }

View file

@ -166,7 +166,7 @@ ircd::m::device::del(const m::user &user,
const auto event_id const auto event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
if(!event_id) if(!event_id)

View file

@ -270,7 +270,7 @@ try
id(json::string(source.at("event_id"))): id(json::string(source.at("event_id"))):
event_id_buf? event_id_buf?
id(event_id_buf): id(event_id_buf):
m::event_id(event_idx, event_id_buf, std::nothrow) m::event_id(std::nothrow, event_idx, event_id_buf)
}; };
assert(fopts); assert(fopts);
@ -292,7 +292,7 @@ catch(const json::parse_error &e)
{ {
event_id_buf? event_id_buf?
id(event_id_buf): id(event_id_buf):
m::event_id(event_idx, event_id_buf, std::nothrow) m::event_id(std::nothrow, event_idx, event_id_buf)
}; };
log::critical log::critical
@ -326,7 +326,7 @@ try
id{json::get<"event_id"_>(event)}: id{json::get<"event_id"_>(event)}:
event_id_buf? event_id_buf?
id{event_id_buf}: id{event_id_buf}:
m::event_id(event_idx, event_id_buf, std::nothrow) m::event_id(std::nothrow, event_idx, event_id_buf)
}; };
assert(event_id); assert(event_id);
@ -341,7 +341,7 @@ catch(const json::parse_error &e)
{ {
event_id_buf? event_id_buf?
id(event_id_buf): id(event_id_buf):
m::event_id(event_idx, event_id_buf, std::nothrow) m::event_id(std::nothrow, event_idx, event_id_buf)
}; };
log::critical log::critical

View file

@ -17,11 +17,11 @@ ircd::m::event_id(const event::idx &event_idx)
} }
ircd::m::event::id::buf ircd::m::event::id::buf
ircd::m::event_id(const event::idx &event_idx, ircd::m::event_id(std::nothrow_t,
std::nothrow_t) const event::idx &event_idx)
{ {
event::id::buf ret; event::id::buf ret;
event_id(event_idx, ret, std::nothrow); event_id(std::nothrow, event_idx, ret);
return ret; return ret;
} }
@ -31,35 +31,38 @@ ircd::m::event_id(const event::idx &event_idx,
{ {
const event::id ret const event::id ret
{ {
event_id(event_idx, buf, std::nothrow) event_id(std::nothrow, event_idx, buf)
}; };
if(!ret) if(!ret)
throw m::NOT_FOUND throw m::NOT_FOUND
{ {
"Cannot find event ID from idx[%lu]", event_idx "Cannot find event ID from idx[%lu]",
event_idx
}; };
return ret; return ret;
} }
ircd::m::event::id ircd::m::event::id
ircd::m::event_id(const event::idx &event_idx, ircd::m::event_id(std::nothrow_t,
event::id::buf &buf, const event::idx &event_idx,
std::nothrow_t) event::id::buf &buf)
{ {
event_id(event_idx, std::nothrow, [&buf] event_id(std::nothrow, event_idx, [&buf]
(const event::id &eid) (const event::id &eid)
{ {
buf = eid; buf = eid;
}); });
return buf? event::id{buf} : event::id{}; return buf?
event::id{buf}:
event::id{};
} }
bool bool
ircd::m::event_id(const event::idx &event_idx, ircd::m::event_id(std::nothrow_t,
std::nothrow_t, const event::idx &event_idx,
const event::id::closure &closure) const event::id::closure &closure)
{ {
return get(std::nothrow, event_idx, "event_id", closure); return get(std::nothrow, event_idx, "event_id", closure);

View file

@ -572,7 +572,7 @@ ircd::m::top(std::nothrow_t,
event::id::buf{}, depth, event_idx event::id::buf{}, depth, event_idx
}; };
m::event_id(event_idx, std::nothrow, [&ret] m::event_id(std::nothrow, event_idx, [&ret]
(const event::id &event_id) (const event::id &event_id)
{ {
std::get<event::id::buf>(ret) = event_id; std::get<event::id::buf>(ret) = event_id;
@ -1283,7 +1283,7 @@ const
(const event::idx &idx) (const event::idx &idx)
{ {
bool ret{true}; bool ret{true};
m::event_id(idx, std::nothrow, [&ret, &closure] m::event_id(std::nothrow, idx, [&ret, &closure]
(const event::id &event_id) (const event::id &event_id)
{ {
ret = closure(event_id); ret = closure(event_id);

View file

@ -167,7 +167,7 @@ ircd::m::room::aliases::cache::del(const alias &alias)
const auto event_id const auto event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
if(!event_id) if(!event_id)

View file

@ -112,7 +112,7 @@ ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf,
}; };
if(existing_join) if(existing_join)
event_id_buf = m::event_id(member_event_idx, std::nothrow); event_id_buf = m::event_id(std::nothrow, member_event_idx);
if(!event_id_buf) if(!event_id_buf)
event_id_buf = m::bootstrap::make_join(host, room_id, user_id, room_version_buf); event_id_buf = m::bootstrap::make_join(host, room_id, user_id, room_version_buf);

View file

@ -154,7 +154,7 @@ try
const auto event_id const auto event_id
{ {
m::event_id(it.event_idx(), std::nothrow) m::event_id(std::nothrow, it.event_idx())
}; };
if(unlikely(!event_id)) if(unlikely(!event_id))

View file

@ -77,7 +77,7 @@ ircd::m::join(const m::room &room,
const event::id::buf event_id const event::id::buf event_id
{ {
event_idx? event_idx?
m::event_id(event_idx, std::nothrow): m::event_id(std::nothrow, event_idx):
event::id::buf{} event::id::buf{}
}; };

View file

@ -136,7 +136,7 @@ const
get(type, state_key, event::closure_idx{[&] get(type, state_key, event::closure_idx{[&]
(const event::idx &idx) (const event::idx &idx)
{ {
if(!m::event_id(idx, std::nothrow, closure)) if(!m::event_id(std::nothrow, idx, closure))
throw m::NOT_FOUND throw m::NOT_FOUND
{ {
"(%s,%s) in %s idx:%lu event_id :not found", "(%s,%s) in %s idx:%lu event_id :not found",
@ -214,7 +214,7 @@ const
return get(std::nothrow, type, state_key, event::closure_idx{[&closure] return get(std::nothrow, type, state_key, event::closure_idx{[&closure]
(const event::idx &idx) (const event::idx &idx)
{ {
m::event_id(idx, std::nothrow, closure); m::event_id(std::nothrow, idx, closure);
}}); }});
} }
@ -405,7 +405,7 @@ const
(const event::idx &idx) (const event::idx &idx)
{ {
bool ret{true}; bool ret{true};
m::event_id(idx, std::nothrow, [&ret, &closure] m::event_id(std::nothrow, idx, [&ret, &closure]
(const event::id &id) (const event::id &id)
{ {
ret = closure(id); ret = closure(id);
@ -607,7 +607,7 @@ const
(const event::idx &idx) (const event::idx &idx)
{ {
bool ret{true}; bool ret{true};
m::event_id(idx, std::nothrow, [&ret, &closure] m::event_id(std::nothrow, idx, [&ret, &closure]
(const event::id &id) (const event::id &id)
{ {
ret = closure(id); ret = closure(id);

View file

@ -29,7 +29,7 @@ const
const m::event::id::buf event_id const m::event::id::buf event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
if(!event_id) if(!event_id)

View file

@ -35,7 +35,7 @@ const
const m::event::id::buf event_id const m::event::id::buf event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
if(!event_id) if(!event_id)

View file

@ -290,7 +290,7 @@ ircd::m::sync::_room_timeline_polylog_events(data &data,
ret |= _room_timeline_append(data, array, it.event_idx(), event); ret |= _room_timeline_append(data, array, it.event_idx(), event);
} }
return m::event_id(event_idx, std::nothrow); return m::event_id(std::nothrow, event_idx);
} }
bool bool

View file

@ -7497,7 +7497,7 @@ console_cmd__event__horizon(opt &out, const string_view &line)
{ {
const auto _event_id const auto _event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
out << event_id out << event_id
@ -7522,7 +7522,7 @@ console_cmd__event__horizon__list(opt &out, const string_view &line)
{ {
const auto _event_id const auto _event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
out << event_id out << event_id

View file

@ -259,7 +259,7 @@ send_join__response(client &client,
{ {
const auto &event_id const auto &event_id
{ {
m::event_id(event_idx, std::nothrow) m::event_id(std::nothrow, event_idx)
}; };
if(event_id) if(event_id)

View file

@ -97,7 +97,7 @@ get__state_ids(client &client,
ac.for_each([&auth_chain_ids] ac.for_each([&auth_chain_ids]
(const m::event::idx &event_idx) (const m::event::idx &event_idx)
{ {
m::event_id(event_idx, std::nothrow, [&auth_chain_ids] m::event_id(std::nothrow, event_idx, [&auth_chain_ids]
(const auto &event_id) (const auto &event_id)
{ {
auth_chain_ids.append(event_id); auth_chain_ids.append(event_id);

View file

@ -1097,7 +1097,7 @@ github_handle__status(std::ostream &out,
if(!m::query(std::nothrow, it.event_idx(), "content", content_match)) if(!m::query(std::nothrow, it.event_idx(), "content", content_match))
continue; continue;
push_event_id = m::event_id(it.event_idx(), std::nothrow); push_event_id = m::event_id(std::nothrow, it.event_idx());
break; break;
} }
} }