mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 13:01:07 +01:00
modules/client: Minor upgrades to std::clamp/std::minmax templates.
This commit is contained in:
parent
ec6c3bbc0f
commit
9bb4936625
5 changed files with 27 additions and 30 deletions
|
@ -122,14 +122,14 @@ m::resource::response
|
|||
post__keys_claim(client &client,
|
||||
const m::resource::request &request)
|
||||
{
|
||||
const milliseconds timeout{[&request]
|
||||
const milliseconds
|
||||
timeout_min{claim_timeout_min},
|
||||
timeout_max{claim_timeout_max},
|
||||
timeout_default{claim_timeout_default},
|
||||
timeout
|
||||
{
|
||||
const milliseconds _default(claim_timeout_default);
|
||||
milliseconds ret(request.get("timeout", _default));
|
||||
ret = std::max(ret, milliseconds(claim_timeout_min));
|
||||
ret = std::min(ret, milliseconds(claim_timeout_max));
|
||||
return ret;
|
||||
}()};
|
||||
std::clamp(request.get("timeout", timeout_default), timeout_min, timeout_max)
|
||||
};
|
||||
|
||||
const json::object &one_time_keys
|
||||
{
|
||||
|
|
|
@ -121,14 +121,14 @@ m::resource::response
|
|||
post__keys_query(client &client,
|
||||
const m::resource::request &request)
|
||||
{
|
||||
const milliseconds timeout{[&request]
|
||||
const milliseconds
|
||||
timeout_min{query_timeout_min},
|
||||
timeout_max{query_timeout_max},
|
||||
timeout_default{query_timeout_default},
|
||||
timeout
|
||||
{
|
||||
const milliseconds _default(query_timeout_default);
|
||||
milliseconds ret(request.get("timeout", _default));
|
||||
ret = std::max(ret, milliseconds(query_timeout_min));
|
||||
ret = std::min(ret, milliseconds(query_timeout_max));
|
||||
return ret;
|
||||
}()};
|
||||
std::clamp(request.get("timeout", timeout_default), timeout_min, timeout_max)
|
||||
};
|
||||
|
||||
const auto &token
|
||||
{
|
||||
|
|
|
@ -63,11 +63,10 @@ get__context(client &client,
|
|||
url::decode(event_id, request.parv[2])
|
||||
};
|
||||
|
||||
const auto limit{[&request]
|
||||
const auto &limit
|
||||
{
|
||||
auto ret(request.query.get<size_t>("limit", default_limit));
|
||||
return std::min(ret, size_t(limit_max));
|
||||
}()};
|
||||
std::min(request.query.get<size_t>("limit", default_limit), size_t(limit_max))
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
|
|
|
@ -1106,17 +1106,15 @@ try
|
|||
{
|
||||
uint64_t(lex_cast<int64_t>(next_batch_token?: "-1"_sv))
|
||||
}
|
||||
,timesout{[&request]
|
||||
,timesout
|
||||
{
|
||||
auto ret
|
||||
{
|
||||
request.query.get("timeout", milliseconds(timeout_default))
|
||||
};
|
||||
|
||||
ret = std::min(ret, milliseconds(timeout_max));
|
||||
ret = std::max(ret, milliseconds(timeout_min));
|
||||
return now<system_point>() + ret;
|
||||
}()}
|
||||
std::clamp
|
||||
(
|
||||
request.query.get("timeout", milliseconds(timeout_default)),
|
||||
milliseconds(timeout_min),
|
||||
milliseconds(timeout_max)
|
||||
)
|
||||
}
|
||||
,full_state
|
||||
{
|
||||
request.query.get("full_state", false)
|
||||
|
|
|
@ -204,7 +204,7 @@ ircd::m::sync::_notification_count(const room &room,
|
|||
{
|
||||
const event::idx_range range
|
||||
{
|
||||
std::min(a, b), std::max(a, b)
|
||||
std::minmax(a, b)
|
||||
};
|
||||
|
||||
return room::events::count(room, range);
|
||||
|
@ -223,7 +223,7 @@ ircd::m::sync::_highlight_count(const room &room,
|
|||
|
||||
const event::idx_range range
|
||||
{
|
||||
std::min(a, b), std::max(a, b)
|
||||
std::minmax(a, b)
|
||||
};
|
||||
|
||||
return highlight.count_between(room, range);
|
||||
|
|
Loading…
Reference in a new issue