From d2680c18d36148cd87582ec4adc6f38b27e249db Mon Sep 17 00:00:00 2001 From: Marcus Müller <mmueller@gnuradio.org> Date: Sun, 21 Mar 2021 21:08:16 +0100 Subject: runtime: don't do two lookups to verify existence and get msg handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcus Müller <mmueller@gnuradio.org> --- gnuradio-runtime/lib/basic_block.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnuradio-runtime/lib/basic_block.cc') diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc index 6061026a56..52a1a5e16b 100644 --- a/gnuradio-runtime/lib/basic_block.cc +++ b/gnuradio-runtime/lib/basic_block.cc @@ -173,15 +173,15 @@ void basic_block::_post(pmt::pmt_t which_port, pmt::pmt_t msg) void basic_block::insert_tail(pmt::pmt_t which_port, pmt::pmt_t msg) { gr::thread::scoped_lock guard(mutex); - - if (msg_queue.find(which_port) == msg_queue.end()) { + const auto& queue = msg_queue.find(which_port); + if (queue == msg_queue.end()) { GR_LOG_ERROR(d_logger, std::string("attempted insertion on invalid queue ") + pmt::symbol_to_string(which_port)); throw std::runtime_error("attempted to insert_tail on invalid queue!"); } - msg_queue[which_port].push_back(msg); + queue->second.push_back(msg); // wake up thread if BLKD_IN or BLKD_OUT global_block_registry.notify_blk(d_symbol_name); -- cgit v1.2.3