0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-28 16:15:23 +08:00

Problem: complex unnecessary ternary expressions

Solution: simplify to comparison against 0
This commit is contained in:
Simon Giesecke 2018-05-25 22:59:13 +02:00
parent 1432011277
commit eacc805646
9 changed files with 13 additions and 13 deletions

View File

@ -141,7 +141,7 @@ int zmq::dist_t::send_to_all (msg_t *msg_)
int zmq::dist_t::send_to_matching (msg_t *msg_)
{
// Is this end of a multipart message?
bool msg_more = msg_->flags () & msg_t::more ? true : false;
bool msg_more = (msg_->flags () & msg_t::more) != 0;
// Push the message to matching pipes.
distribute (msg_);

View File

@ -99,7 +99,7 @@ int zmq::fq_t::recvpipe (msg_t *msg_, pipe_t **pipe_)
if (fetched) {
if (pipe_)
*pipe_ = pipes[current];
more = msg_->flags () & msg_t::more ? true : false;
more = (msg_->flags () & msg_t::more) != 0;
if (!more) {
last_in = pipes[current];
current = (current + 1) % active;

View File

@ -85,7 +85,7 @@ int zmq::lb_t::sendpipe (msg_t *msg_, pipe_t **pipe_)
// Drop the message if required. If we are at the end of the message
// switch back to non-dropping mode.
if (dropping) {
more = msg_->flags () & msg_t::more ? true : false;
more = (msg_->flags () & msg_t::more) != 0;
dropping = more;
int rc = msg_->close ();
@ -127,7 +127,7 @@ int zmq::lb_t::sendpipe (msg_t *msg_, pipe_t **pipe_)
// If it's final part of the message we can flush it downstream and
// continue round-robining (load balance).
more = msg_->flags () & msg_t::more ? true : false;
more = (msg_->flags () & msg_t::more) != 0;
if (!more) {
pipes[current]->flush ();

View File

@ -233,7 +233,7 @@ bool zmq::pipe_t::write (msg_t *msg_)
if (unlikely (!check_write ()))
return false;
bool more = msg_->flags () & msg_t::more ? true : false;
bool more = (msg_->flags () & msg_t::more) != 0;
const bool is_routing_id = msg_->is_routing_id ();
outpipe->write (*msg_, more);
if (!more && !is_routing_id)

View File

@ -254,7 +254,7 @@ int zmq::router_t::xsend (msg_t *msg_)
msg_->reset_flags (msg_t::more);
// Check whether this is the last part of the message.
more_out = msg_->flags () & msg_t::more ? true : false;
more_out = (msg_->flags () & msg_t::more) != 0;
// Push the message into the pipe. If there's no out pipe, just drop it.
if (current_out) {
@ -310,7 +310,7 @@ int zmq::router_t::xrecv (msg_t *msg_)
errno_assert (rc == 0);
prefetched = false;
}
more_in = msg_->flags () & msg_t::more ? true : false;
more_in = (msg_->flags () & msg_t::more) != 0;
if (!more_in) {
if (terminate_current_in) {
@ -338,7 +338,7 @@ int zmq::router_t::xrecv (msg_t *msg_)
// If we are in the middle of reading a message, just return the next part.
if (more_in) {
more_in = msg_->flags () & msg_t::more ? true : false;
more_in = (msg_->flags () & msg_t::more) != 0;
if (!more_in) {
if (terminate_current_in) {

View File

@ -156,7 +156,7 @@ int zmq::session_base_t::pull_msg (msg_t *msg_)
return -1;
}
incomplete_in = msg_->flags () & msg_t::more ? true : false;
incomplete_in = (msg_->flags () & msg_t::more) != 0;
return 0;
}

View File

@ -1576,7 +1576,7 @@ void zmq::socket_base_t::extract_flags (msg_t *msg_)
zmq_assert (options.recv_routing_id);
// Remove MORE flag.
rcvmore = msg_->flags () & msg_t::more ? true : false;
rcvmore = (msg_->flags () & msg_t::more) != 0;
}
int zmq::socket_base_t::monitor (const char *addr_, int events_)

View File

@ -230,7 +230,7 @@ void zmq::xpub_t::mark_as_matching (pipe_t *pipe_, xpub_t *self_)
int zmq::xpub_t::xsend (msg_t *msg_)
{
bool msg_more = msg_->flags () & msg_t::more ? true : false;
bool msg_more = (msg_->flags () & msg_t::more) != 0;
// For the first part of multi-part message, find the matching pipes.
if (!more) {

View File

@ -134,7 +134,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_)
int rc = msg_->move (message);
errno_assert (rc == 0);
has_message = false;
more = msg_->flags () & msg_t::more ? true : false;
more = (msg_->flags () & msg_t::more) != 0;
return 0;
}
@ -153,7 +153,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_)
// Check whether the message matches at least one subscription.
// Non-initial parts of the message are passed
if (more || !options.filter || match (msg_)) {
more = msg_->flags () & msg_t::more ? true : false;
more = (msg_->flags () & msg_t::more) != 0;
return 0;
}