0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 15:04:10 +01:00

Add noexcept to various lambdas (gcc-12).

This commit is contained in:
Jason Volk 2022-07-04 13:15:53 -07:00
parent 934d76e81d
commit 3451a989ac
37 changed files with 110 additions and 90 deletions

View file

@ -75,7 +75,8 @@ ircd::m::event::prev::ids(event::id (&out)[N])
const
{
size_t i(0);
m::for_each(*this, [&i, &out](const event::id &event_id)
m::for_each(*this, [&i, &out]
(const event::id &event_id) noexcept
{
out[i++] = event_id;
return i < N;

View file

@ -1360,7 +1360,7 @@ ircd::ctx::context::join()
assert(bool(c));
mark(prof::event::JOIN);
ctx::adjoindre.wait([this]
ctx::adjoindre.wait([this]() noexcept
{
return joined();
});

View file

@ -278,7 +278,7 @@ void
ircd::m::app::worker()
try
{
child.dock.wait([this]
child.dock.wait([this]() noexcept
{
return child.pid >= 0;
});

View file

@ -195,8 +195,9 @@ bool
ircd::m::bridge::config::exists(const string_view &id)
{
return get(std::nothrow, id, []
(const auto &, const auto &, const auto &)
(const auto &, const auto &, const auto &) noexcept
{
// no action
});
}

View file

@ -1076,7 +1076,7 @@ ircd::m::bad(const id::event &event_id)
{
bool ret {false};
index(std::nothrow, event_id, [&ret]
(const event::idx &event_idx)
(const event::idx &event_idx) noexcept
{
ret = event_idx == 0;
});

View file

@ -66,7 +66,8 @@ size_t
ircd::m::count(const event::prev &prev)
{
size_t ret{0};
m::for_each(prev, [&ret](const event::id &event_id)
m::for_each(prev, [&ret]
(const event::id &event_id) noexcept
{
++ret;
return true;

View file

@ -75,7 +75,7 @@ ircd::m::event::refs::rebuild()
++i;
}
dock.wait([&i, &j]
dock.wait([&i, &j]() noexcept
{
return i == j;
});
@ -133,7 +133,7 @@ const
{
size_t ret(0);
for_each(type, [&ret]
(const event::idx &, const dbs::ref &)
(const event::idx &, const dbs::ref &) noexcept
{
++ret;
return true;
@ -154,7 +154,7 @@ ircd::m::event::refs::has(const dbs::ref &type)
const
{
return !for_each(type, [&type]
(const event::idx &, const dbs::ref &ref)
(const event::idx &, const dbs::ref &ref) noexcept
{
assert(ref == type);
return false;
@ -167,7 +167,7 @@ ircd::m::event::refs::has(const dbs::ref &type,
const
{
return !for_each(type, [&idx]
(const event::idx &ref, const dbs::ref &)
(const event::idx &ref, const dbs::ref &) noexcept
{
return ref != idx; // true to continue, false to break
});

View file

@ -556,7 +556,7 @@ ircd::m::events::type::has(const string_view &type)
{
bool ret{false};
for_each(type, [&ret, &type]
(const string_view &type_)
(const string_view &type_) noexcept
{
ret = type == type_;
return false; // uncond break out of loop after first result
@ -570,7 +570,7 @@ ircd::m::events::type::has_prefix(const string_view &type)
{
bool ret{false};
for_each(type, [&ret, &type]
(const string_view &type_)
(const string_view &type_) noexcept
{
ret = startswith(type_, type);
return false; // uncond break out of loop after first result

View file

@ -129,7 +129,7 @@ ircd::m::init::backfill::worker_context;
decltype(ircd::m::init::backfill::handle_quit)
ircd::m::init::backfill::handle_quit
{
run::level::QUIT, []
run::level::QUIT, []() noexcept
{
term();
}

View file

@ -288,7 +288,7 @@ size_t
ircd::m::keys::fetch(const queries &queries)
{
size_t ret(0);
get(queries, [&ret](const auto &)
get(queries, [&ret](const auto &) noexcept
{
++ret;
return true;

View file

@ -392,7 +392,7 @@ try
};
power.for_each("notifications", [&required_level, &key]
(const auto &name, const auto &level)
(const auto &name, const auto &level) noexcept
{
if(name == key)
{

View file

@ -489,7 +489,11 @@ ircd::m::exists(const id::room_alias &room_alias,
if(!remote_query)
return false;
return room::aliases::cache::get(std::nothrow, room_alias, [](const room::id &room_id) {});
return room::aliases::cache::get(std::nothrow, room_alias, []
(const room::id &) noexcept
{
// no action
});
}
int64_t
@ -1407,7 +1411,7 @@ const
if(!match)
column(byte_view<string_view>(event_idx), std::nothrow, [&match, &type]
(const string_view &value)
(const string_view &value) noexcept
{
match = value == type;
});

View file

@ -44,7 +44,8 @@ ircd::m::room::aliases::count(const string_view &server)
const
{
size_t ret(0);
for_each(server, [&ret](const auto &a)
for_each(server, [&ret]
(const auto &a) noexcept
{
++ret;
return true;
@ -58,7 +59,7 @@ ircd::m::room::aliases::has(const alias &alias)
const
{
return !for_each(alias.host(), [&alias]
(const id::room_alias &a)
(const id::room_alias &a) noexcept
{
assert(a.host() == alias.host());
return a == alias? false : true; // false to break on found

View file

@ -660,28 +660,28 @@ ircd::m::room::auth::hookdata::hookdata(const m::event &event,
}
,auth_create
{
find([](const auto &event)
find([](const auto &event) noexcept
{
return json::get<"type"_>(event) == "m.room.create";
})
}
,auth_power
{
find([](const auto &event)
find([](const auto &event) noexcept
{
return json::get<"type"_>(event) == "m.room.power_levels";
})
}
,auth_join_rules
{
find([](const auto &event)
find([](const auto &event) noexcept
{
return json::get<"type"_>(event) == "m.room.join_rules";
})
}
,auth_member_target
{
find([&event](const auto &auth_event)
find([&event](const auto &auth_event) noexcept
{
return json::get<"type"_>(auth_event) == "m.room.member" &&
json::get<"state_key"_>(auth_event) == json::get<"state_key"_>(event);
@ -689,7 +689,7 @@ ircd::m::room::auth::hookdata::hookdata(const m::event &event,
}
,auth_member_sender
{
find([&event](const auto &auth_event)
find([&event](const auto &auth_event) noexcept
{
return json::get<"type"_>(auth_event) == "m.room.member" &&
json::get<"state_key"_>(auth_event) == json::get<"sender"_>(event);
@ -725,7 +725,8 @@ ircd::m::room::auth::refs::count(const string_view &type)
const
{
size_t ret(0);
for_each(type, [&ret](const auto &)
for_each(type, [&ret]
(const auto &) noexcept
{
++ret;
return true;
@ -738,7 +739,8 @@ bool
ircd::m::room::auth::refs::has(const event::idx &idx)
const
{
return !for_each([&idx](const event::idx &ref)
return !for_each([&idx]
(const event::idx &ref) noexcept
{
return ref != idx; // true to continue, false to break
});
@ -749,7 +751,8 @@ ircd::m::room::auth::refs::has(const string_view &type)
const
{
bool ret{false};
for_each(type, [&ret](const auto &)
for_each(type, [&ret]
(const auto &) noexcept
{
ret = true;
return false;
@ -782,7 +785,7 @@ const
bool match;
const auto matcher
{
[&type, &match](const string_view &type_)
[&type, &match](const string_view &type_) noexcept
{
match = type == type_;
}
@ -814,7 +817,8 @@ ircd::m::room::auth::chain::depth()
const
{
size_t ret(0);
for_each([&ret](const auto &)
for_each([&ret]
(const auto &) noexcept
{
++ret;
return true;
@ -832,7 +836,7 @@ const
(const auto &idx)
{
m::get(std::nothrow, idx, "type", [&type, &ret]
(const auto &value)
(const auto &value) noexcept
{
ret = value == type;
});

View file

@ -56,7 +56,7 @@ ircd::m::twain(const room &room)
};
s.rfor_each([&ret]
(const auto &range, const auto &event_idx)
(const auto &range, const auto &event_idx) noexcept
{
ret.first = range.first - 1;
return false;
@ -79,7 +79,7 @@ ircd::m::sounding(const room &room)
};
s.rfor_each([&ret]
(const auto &range, const auto &event_idx)
(const auto &range, const auto &event_idx) noexcept
{
ret.first = range.second;
ret.second = event_idx;
@ -103,7 +103,7 @@ ircd::m::hazard(const room &room)
};
s.for_each([&ret]
(const auto &range, const auto &event_idx)
(const auto &range, const auto &event_idx) noexcept
{
ret.first = range.first;
return false;
@ -438,7 +438,7 @@ const
{
size_t ret{0};
for_each([&ret]
(const auto &event_id, const auto &depth, const auto &event_idx)
(const auto &event_id, const auto &depth, const auto &event_idx) noexcept
{
++ret;
return true;
@ -662,7 +662,7 @@ const
{
size_t ret{0};
for_each([&ret]
(const auto &event_id, const auto &depth, const auto &event_idx)
(const auto &event_id, const auto &depth, const auto &event_idx) noexcept
{
++ret;
return true;
@ -677,7 +677,7 @@ const
{
const std::function<bool (const string_view &)> in_room
{
[this](const string_view &room_id)
[this](const string_view &room_id) noexcept
{
return room_id == this->room.room_id;
}

View file

@ -225,7 +225,7 @@ const
{
size_t ret(0);
for_each([&ret]
(const event::idx &event_idx, const event::id &event_id)
(const event::idx &event_idx, const event::id &event_id) noexcept
{
++ret;
return true;
@ -240,7 +240,7 @@ const
{
bool ret{false};
for_each([&ret, &event_id]
(const event::idx &event_idx, const event::id &event_id_)
(const event::idx &event_idx, const event::id &event_id_) noexcept
{
ret = event_id_ == event_id;
return !ret; // for_each protocol: false to break

View file

@ -28,7 +28,7 @@ ircd::m::room::members::empty(const string_view &membership,
const
{
return for_each(membership, host, closure{[]
(const user::id &user_id)
(const user::id &user_id) noexcept
{
return false;
}});
@ -55,7 +55,7 @@ const
{
size_t ret{0};
for_each(membership, host, closure{[&ret]
(const user::id &user_id)
(const user::id &user_id) noexcept
{
++ret;
return true;

View file

@ -90,7 +90,7 @@ ircd::m::room::origins::empty()
const
{
return for_each(closure_bool{[]
(const string_view &)
(const string_view &) noexcept
{
// return false to break and return false.
return false;
@ -102,7 +102,8 @@ ircd::m::room::origins::count()
const
{
size_t ret{0};
for_each([&ret](const string_view &)
for_each([&ret]
(const string_view &) noexcept
{
++ret;
});
@ -150,7 +151,7 @@ const
{
ushort ret{2};
for_each(closure_bool{[&ret, &origin]
(const string_view &origin_) -> bool
(const string_view &origin_) noexcept -> bool
{
if(origin == origin_)
ret = 1;

View file

@ -551,7 +551,7 @@ const
{
size_t ret{0};
for_each([&ret]
(const string_view &, const int64_t &)
(const string_view &, const int64_t &) noexcept
{
++ret;
return true;
@ -581,7 +581,7 @@ const
{
size_t ret{0};
for_each(prop, [&ret]
(const string_view &, const int64_t &)
(const string_view &, const int64_t &) noexcept
{
++ret;
return true;

View file

@ -173,7 +173,7 @@ const
};
return !for_each(prop, [&server]
(const string_view &expression)
(const string_view &expression) noexcept
{
const globular_imatch match
{
@ -191,7 +191,7 @@ ircd::m::room::server_acl::has(const string_view &prop,
const
{
return !for_each(prop, [&expr]
(const string_view &_expr)
(const string_view &_expr) noexcept
{
// false to break on match
return _expr == expr? false : true;
@ -240,7 +240,7 @@ const
{
size_t ret(0);
for_each(prop, [&ret]
(const string_view &)
(const string_view &) noexcept
{
++ret;
return true;

View file

@ -85,7 +85,7 @@ const
{
event::idx ret;
get(type, state_key, event::closure_idx{[&ret]
(const event::idx &event_idx)
(const event::idx &event_idx) noexcept
{
ret = event_idx;
}});
@ -101,7 +101,7 @@ const
{
event::idx ret{0};
get(std::nothrow, type, state_key, event::closure_idx{[&ret]
(const event::idx &event_idx)
(const event::idx &event_idx) noexcept
{
ret = event_idx;
}});
@ -295,7 +295,7 @@ const
}
return !for_each(type, []
(const string_view &, const string_view &, const event::idx &)
(const string_view &, const string_view &, const event::idx &) noexcept
{
return false;
});
@ -366,7 +366,7 @@ const
size_t ret(0);
for_each(type, [&ret]
(const string_view &, const string_view &, const event::idx &)
(const string_view &, const string_view &, const event::idx &) noexcept
{
++ret;
return true;
@ -755,7 +755,7 @@ ircd::m::room::state::is(const event::idx &event_idx)
{
bool ret{false};
m::get(event_idx, "state_key", [&ret]
(const string_view &state_key)
(const string_view &state_key) noexcept
{
ret = true;
});
@ -769,7 +769,7 @@ ircd::m::room::state::is(std::nothrow_t,
{
bool ret{false};
m::get(std::nothrow, event_idx, "state_key", [&ret]
(const string_view &state_key)
(const string_view &state_key) noexcept
{
ret = true;
});
@ -797,7 +797,8 @@ ircd::m::room::state::purge_replaced(const room::id &room_id)
for(; it; ++it)
{
const m::event::idx &event_idx(it.event_idx());
if(!m::get(std::nothrow, event_idx, "state_key", [](const auto &) {}))
static const auto no_action{[](const auto &) noexcept {}};
if(!m::get(std::nothrow, event_idx, "state_key", no_action))
continue;
if(!m::event::refs(event_idx).count(m::dbs::ref::NEXT_STATE))
@ -846,7 +847,7 @@ ircd::m::room::state::prev(const event::idx &event_idx)
{
event::idx ret{0};
prev(event_idx, [&ret]
(const event::idx &event_idx)
(const event::idx &event_idx) noexcept
{
if(event_idx > ret)
ret = event_idx;
@ -862,7 +863,7 @@ ircd::m::room::state::next(const event::idx &event_idx)
{
event::idx ret{0};
next(event_idx, [&ret]
(const event::idx &event_idx)
(const event::idx &event_idx) noexcept
{
if(event_idx > ret)
ret = event_idx;

View file

@ -102,7 +102,7 @@ const
event::idx ret{0};
assert(type && defined(state_key));
for_each(type, state_key, [&ret]
(const auto &, const auto &, const auto &, const auto &event_idx)
(const auto &, const auto &, const auto &, const auto &event_idx) noexcept
{
ret = event_idx;
return false;
@ -124,7 +124,7 @@ ircd::m::room::state::history::has(const string_view &type,
const
{
return !for_each(type, state_key, []
(const auto &type, const auto &state_key, const auto &depth, const auto &event_idx)
(const auto &, const auto &, const auto &, const auto &) noexcept
{
return false;
});
@ -144,7 +144,7 @@ const
{
size_t ret(0);
for_each(type, state_key, [&ret]
(const auto &type, const auto &state_key, const auto &depth, const auto &event_idx)
(const auto &, const auto &, const auto &, const auto &) noexcept
{
++ret;
return true;

View file

@ -73,7 +73,7 @@ ircd::m::room::state::space::has(const string_view &type,
const
{
return !for_each(type, state_key, depth, []
(const auto &type, const auto &state_key, const auto &depth, const auto &event_idx)
(const auto &, const auto &, const auto &, const auto &) noexcept
{
return false;
});
@ -109,7 +109,7 @@ const
{
size_t ret(0);
for_each(type, state_key, depth, [&ret]
(const auto &type, const auto &state_key, const auto &depth, const auto &event_idx)
(const auto &, const auto &, const auto &, const auto &) noexcept
{
++ret;
return true;

View file

@ -34,7 +34,7 @@ ircd::m::room::type::empty()
const
{
return for_each([]
(const auto &type, const auto &depth, const auto &event_idx)
(const auto &type, const auto &depth, const auto &event_idx) noexcept
{
return false;
});
@ -46,7 +46,7 @@ const
{
size_t ret(0);
for_each([&ret]
(const auto &type, const auto &depth, const auto &event_idx)
(const auto &type, const auto &depth, const auto &event_idx) noexcept
{
++ret;
return true;

View file

@ -64,7 +64,7 @@ bool
ircd::m::rooms::has(const opts &opts)
{
return !for_each(opts, []
(const m::room::id &)
(const m::room::id &) noexcept
{
// false to break; for_each() returns false
return false;
@ -76,7 +76,7 @@ ircd::m::rooms::count(const opts &opts)
{
size_t ret{0};
for_each(opts, [&ret]
(const m::room::id &)
(const m::room::id &) noexcept
{
++ret;
return true;
@ -216,7 +216,7 @@ ircd::m::rooms::for_each(const opts &opts,
{
++prefetch;
prefetched += m::prefetch(event_idx, "room_id");
dock.wait([&]
dock.wait([&]() noexcept
{
return fetch + opts.prefetch > prefetch;
});

View file

@ -461,7 +461,7 @@ const
{
size_t ret(0);
sync::for_each(this->name(), [&ret]
(auto &item)
(auto &item) noexcept
{
++ret;
return true;

View file

@ -89,7 +89,7 @@ ircd::m::txn::create(const closure &closure,
{
iov, !empty(pdu),
{
"pdus", [&pdu]() -> json::value
"pdus", [&pdu]() noexcept -> json::value
{
return { data(pdu), size(pdu) };
}
@ -100,7 +100,7 @@ ircd::m::txn::create(const closure &closure,
{
iov, !empty(edu),
{
"edus", [&edu]() -> json::value
"edus", [&edu]() noexcept -> json::value
{
return { data(edu), size(edu) };
}
@ -111,7 +111,7 @@ ircd::m::txn::create(const closure &closure,
{
iov, !empty(pdu_failure),
{
"pdu_failures", [&pdu_failure]() -> json::value
"pdu_failures", [&pdu_failure]() noexcept -> json::value
{
return { data(pdu_failure), size(pdu_failure) };
}

View file

@ -237,7 +237,7 @@ const
const bool got
{
get(std::nothrow, id, prop, [&val, &dup]
(const auto &event_idx, const json::string &existing)
(const auto &event_idx, const json::string &existing) noexcept
{
dup = val == existing;
})
@ -293,7 +293,7 @@ const
{
bool ret{false};
get(std::nothrow, id, prop, [&ret]
(const auto &event_idx, const string_view &value)
(const auto &event_idx, const string_view &value) noexcept
{
ret = !empty(value);
});

View file

@ -13,7 +13,7 @@ ircd::m::user::events::count()
const
{
size_t ret{0};
for_each([&ret](const event::idx &)
for_each([&ret](const event::idx &) noexcept
{
++ret;
return true;

View file

@ -33,7 +33,7 @@ ircd::m::user::ignores::has(const m::user::id &other)
const
{
return !for_each([&other]
(const m::user::id &user_id, const json::object &)
(const m::user::id &user_id, const json::object &) noexcept
{
return user_id != other;
});

View file

@ -15,7 +15,7 @@ const
{
// Return true if broken out of loop.
return !for_each(other, membership, []
(const m::room &, const string_view &)
(const m::room &, const string_view &) noexcept
{
// Break out of loop at first shared room
return false;
@ -27,7 +27,8 @@ ircd::m::user::mitsein::count(const string_view &membership)
const
{
size_t ret{0};
for_each(membership, [&ret](const m::user &)
for_each(membership, [&ret]
(const m::user &) noexcept
{
++ret;
return true;
@ -42,7 +43,8 @@ ircd::m::user::mitsein::count(const m::user &user,
const
{
size_t ret{0};
for_each(user, membership, [&ret](const m::room &, const string_view &)
for_each(user, membership, [&ret]
(const m::room &, const string_view &) noexcept
{
++ret;
return true;

View file

@ -58,7 +58,7 @@ ircd::m::user::notifications::empty(const opts &opts)
const
{
return !for_each(opts, closure_meta{[&]
(const auto &, const auto &)
(const auto &, const auto &) noexcept
{
return false;
}});
@ -70,7 +70,7 @@ const
{
size_t ret(0);
for_each(opts, closure_meta{[&ret]
(const auto &, const auto &)
(const auto &, const auto &) noexcept
{
++ret;
return true;

View file

@ -152,7 +152,7 @@ ircd::m::user::profile::fetch(const m::user &user,
{
bool exists{false};
profile.get(std::nothrow, member.first, [&exists, &member]
(const string_view &key, const string_view &val)
(const string_view &key, const string_view &val) noexcept
{
exists = member.second == val;
});

View file

@ -125,7 +125,8 @@ ircd::m::user::pushers::has(const string_view &key)
const
{
return !for_each([&key] // for_each() returns true if no match
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
(const event::idx &, const string_view &pushkey, const push::pusher &)
noexcept
{
return key != pushkey;
});
@ -136,7 +137,8 @@ ircd::m::user::pushers::any(const string_view &kind)
const
{
return !for_each([&kind] // for_each() returns true if no match
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
(const event::idx &, const string_view &, const push::pusher &pusher)
noexcept
{
if(!kind)
return false;
@ -154,7 +156,8 @@ const
{
size_t ret{0};
for_each([&ret, &kind]
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
(const event::idx &, const string_view &, const push::pusher &pusher)
noexcept
{
ret += !kind || json::get<"kind"_>(pusher) == kind;
return true;

View file

@ -14,7 +14,7 @@ const
{
size_t ret{0};
for_each([&ret]
(const m::room &, const string_view &membership)
(const m::room &, const string_view &membership) noexcept
{
++ret;
});
@ -28,7 +28,7 @@ const
{
size_t ret{0};
for_each(membership, [&ret]
(const m::room &, const string_view &membership)
(const m::room &, const string_view &membership) noexcept
{
++ret;
});

View file

@ -21,7 +21,7 @@ bool
ircd::m::users::exists(const opts &opts)
{
return !for_each(opts, []
(const auto &)
(const auto &) noexcept
{
// return false to break and have for_each() returns false
return false;
@ -32,7 +32,8 @@ size_t
ircd::m::users::count(const opts &opts)
{
size_t ret(0);
for_each(opts, [&ret](const auto &)
for_each(opts, [&ret]
(const auto &) noexcept
{
++ret;
return true;

View file

@ -15,7 +15,7 @@ const
{
// Return true if broken out of loop.
return !for_each(membership, []
(const auto &server)
(const auto &server) noexcept
{
// Break out of loop at first shared room
return false;
@ -28,7 +28,7 @@ const
{
size_t ret{0};
for_each(membership, [&ret]
(const auto &server)
(const auto &server) noexcept
{
++ret;
return true;