mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 18:42:43 +01:00
Use std::min/max where possible
This commit is contained in:
@@ -520,8 +520,8 @@ void zmq::pipe_t::hiccup ()
|
|||||||
|
|
||||||
void zmq::pipe_t::set_hwms (int inhwm_, int outhwm_)
|
void zmq::pipe_t::set_hwms (int inhwm_, int outhwm_)
|
||||||
{
|
{
|
||||||
int in = inhwm_ + (_in_hwm_boost > 0 ? _in_hwm_boost : 0);
|
int in = inhwm_ + std::max (_in_hwm_boost, 0);
|
||||||
int out = outhwm_ + (_out_hwm_boost > 0 ? _out_hwm_boost : 0);
|
int out = outhwm_ + std::max (_out_hwm_boost, 0);
|
||||||
|
|
||||||
// if either send or recv side has hwm <= 0 it means infinite so we should set hwms infinite
|
// if either send or recv side has hwm <= 0 it means infinite so we should set hwms infinite
|
||||||
if (inhwm_ <= 0 || _in_hwm_boost == 0)
|
if (inhwm_ <= 0 || _in_hwm_boost == 0)
|
||||||
|
|||||||
@@ -1158,9 +1158,7 @@ int zmq::stream_engine_t::process_heartbeat_message (msg_t *msg_)
|
|||||||
// Given the engine goes straight to out_event, sequential PINGs will
|
// Given the engine goes straight to out_event, sequential PINGs will
|
||||||
// not be a problem.
|
// not be a problem.
|
||||||
const size_t context_len =
|
const size_t context_len =
|
||||||
msg_->size () - ping_ttl_len > ping_max_ctx_len
|
std::min (msg_->size () - ping_ttl_len, ping_max_ctx_len);
|
||||||
? ping_max_ctx_len
|
|
||||||
: msg_->size () - ping_ttl_len;
|
|
||||||
const int rc =
|
const int rc =
|
||||||
_pong_msg.init_size (msg_t::ping_cmd_name_size + context_len);
|
_pong_msg.init_size (msg_t::ping_cmd_name_size + context_len);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ long zmq::timers_t::timeout ()
|
|||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (0 == _cancelled_timers.erase (it->second.timer_id)) {
|
if (0 == _cancelled_timers.erase (it->second.timer_id)) {
|
||||||
// Live timer, lets return the timeout
|
// Live timer, lets return the timeout
|
||||||
res = it->first > now ? static_cast<long> (it->first - now) : 0;
|
res = std::max (static_cast<long> (it->first - now), 0l);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user