From 9b63bb4f4a52c172ea8f4ebf8e0577cf101da69c Mon Sep 17 00:00:00 2001
From: Marcus Müller <mueller@kit.edu>
Date: Tue, 20 Feb 2018 13:03:12 +0100
Subject: qtgui: 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-qtgui/lib/edit_box_msg_impl.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'gr-qtgui/lib/edit_box_msg_impl.cc')

diff --git a/gr-qtgui/lib/edit_box_msg_impl.cc b/gr-qtgui/lib/edit_box_msg_impl.cc
index 084e2d4f34..6dbd54203b 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.cc
+++ b/gr-qtgui/lib/edit_box_msg_impl.cc
@@ -51,7 +51,8 @@ namespace gr {
       : block("edit_box_msg",
               io_signature::make(0, 0, 0),
               io_signature::make(0, 0, 0)),
-        QObject(parent)
+        QObject(parent),
+        d_port(pmt::mp("msg"))
     {
       // Required now for Qt; argc must be greater than 0 and argv
       // must have at least one valid character. Must be valid through
@@ -156,7 +157,7 @@ namespace gr {
 
       d_msg = pmt::PMT_NIL;
 
-      message_port_register_out(pmt::mp("msg"));
+      message_port_register_out(d_port);
       message_port_register_in(pmt::mp("val"));
 
       set_msg_handler(pmt::mp("val"),
@@ -404,7 +405,7 @@ namespace gr {
 
       // Emit the new message to pass updates downstream.
       // Loops are prevented by the early exit if d_msg == val.
-      message_port_pub(pmt::mp("msg"), d_msg);
+      message_port_pub(d_port, d_msg);
     }
 
     void
@@ -560,7 +561,7 @@ namespace gr {
         d_msg = pmt::cons(pmt::intern(key), d_msg);
       }
 
-      message_port_pub(pmt::mp("msg"), d_msg);
+      message_port_pub(d_port, d_msg);
     }
 
   } /* namespace qtgui */
-- 
cgit v1.2.3