From 97f0d1cecf4a8cb82e8e16e4dfcac0589c5b56c7 Mon Sep 17 00:00:00 2001 From: Marcus Müller <mueller@kit.edu> Date: Tue, 20 Feb 2018 11:22:14 +0100 Subject: blocks: remove unnecessary call to pmt::intern at runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typical usage: message_port_pub(pmt::mp("out_port"), …) which is bad, as it implies hashing of a string, allocation of memory, deallocation, finding the hashed string in the table of interned strings and returning a unique pointer (which for reasons of PMT awesomeness isn't even unique) to the interned port name. Replacing all these port name ad hoc ::mp() calls by reusing one, private, port name member. --- gr-blocks/lib/message_strobe_random_impl.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gr-blocks/lib/message_strobe_random_impl.cc') diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc index c62aad1c7a..ab9422717c 100644 --- a/gr-blocks/lib/message_strobe_random_impl.cc +++ b/gr-blocks/lib/message_strobe_random_impl.cc @@ -45,6 +45,7 @@ namespace gr { (new message_strobe_random_impl(msg, dist, mean_ms, std_ms)); } + message_strobe_random_impl::message_strobe_random_impl(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_ms) : block("message_strobe_random", io_signature::make(0, 0, 0), @@ -54,13 +55,14 @@ namespace gr { d_std_ms(std_ms), d_dist(dist), d_msg(msg), - d_rng() + d_rng(), + d_port(pmt::mp("strobe")) { // allocate RNGs update_dist(); // set up ports - message_port_register_out(pmt::mp("strobe")); + message_port_register_out(d_port); d_thread = boost::shared_ptr<gr::thread::thread> (new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this))); @@ -113,7 +115,7 @@ namespace gr { return; } - message_port_pub(pmt::mp("strobe"), d_msg); + message_port_pub(d_port, d_msg); } } -- cgit v1.2.3