From 47dba21005ab84b67d8a1b360e143bec5178ede7 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Sun, 24 Mar 2019 13:46:15 -0400 Subject: [PATCH] Problem: code is unnecessarily imperative Solution: make more functional-style --- src/session_base.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/session_base.cpp b/src/session_base.cpp index 2b4a6daa..5fda4d8c 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -751,19 +751,8 @@ void zmq::session_base_t::start_connecting_udp (io_thread_t * /*io_thread_*/) udp_engine_t *engine = new (std::nothrow) udp_engine_t (options); alloc_assert (engine); - bool recv = false; - bool send = false; - - if (options.type == ZMQ_RADIO) { - send = true; - recv = false; - } else if (options.type == ZMQ_DISH) { - send = false; - recv = true; - } else if (options.type == ZMQ_DGRAM) { - send = true; - recv = true; - } + const bool recv = options.type == ZMQ_DISH || options.type == ZMQ_DGRAM; + const bool send = options.type == ZMQ_RADIO || options.type == ZMQ_DGRAM; const int rc = engine->init (_addr, send, recv); errno_assert (rc == 0);