summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib
diff options
context:
space:
mode:
authorMarcus Müller <mueller@kit.edu>2018-02-20 13:03:12 +0100
committerMarcus Müller <marcus@hostalia.de>2018-02-23 19:06:50 +0100
commit9b63bb4f4a52c172ea8f4ebf8e0577cf101da69c (patch)
tree51c03403bf33ceb33a29d3e3917082d5bb4bd439 /gr-qtgui/lib
parent28401b7a01d9e6f25c6057f7b9dc07c8e568ff60 (diff)
qtgui: remove unnecessary call to pmt::intern at runtime
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.
Diffstat (limited to 'gr-qtgui/lib')
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.cc9
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.h1
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.cc15
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.h2
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.cc13
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.h2
-rw-r--r--gr-qtgui/lib/sink_c_impl.cc13
-rw-r--r--gr-qtgui/lib/sink_c_impl.h2
-rw-r--r--gr-qtgui/lib/sink_f_impl.cc13
-rw-r--r--gr-qtgui/lib/sink_f_impl.h2
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc9
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.h2
-rw-r--r--gr-qtgui/lib/vector_sink_f_impl.cc11
-rw-r--r--gr-qtgui/lib/vector_sink_f_impl.h4
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.cc13
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.h2
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.cc13
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.h2
18 files changed, 77 insertions, 51 deletions
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 */
diff --git a/gr-qtgui/lib/edit_box_msg_impl.h b/gr-qtgui/lib/edit_box_msg_impl.h
index c60b3de9b0..35e86f79e9 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.h
+++ b/gr-qtgui/lib/edit_box_msg_impl.h
@@ -55,6 +55,7 @@ namespace gr {
QComboBox *d_type_box;
pmt::pmt_t d_msg;
+ const pmt::pmt_t d_port;
public:
edit_box_msg_impl(gr::qtgui::data_type_t type,
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index ffa4e3017c..f9125881ce 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -58,8 +58,9 @@ namespace gr {
io_signature::make(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -71,9 +72,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&freq_sink_c_impl::handle_set_freq, this, _1));
// setup PDU handling input port
@@ -585,8 +586,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h
index b102209359..2991891534 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.h
+++ b/gr-qtgui/lib/freq_sink_c_impl.h
@@ -47,6 +47,8 @@ namespace gr {
std::string d_name;
int d_nconnections;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index 3fe2572eb0..831df49ef4 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -59,7 +59,8 @@ namespace gr {
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
+ d_nconnections(nconnections), d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -71,9 +72,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&freq_sink_f_impl::handle_set_freq, this, _1));
// setup PDU handling input port
@@ -590,8 +591,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
index 85d45b3f4c..bed6175aaf 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.h
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -47,6 +47,8 @@ namespace gr {
std::string d_name;
int d_nconnections;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/sink_c_impl.cc b/gr-qtgui/lib/sink_c_impl.cc
index ba34eaaa32..77f87c1e0c 100644
--- a/gr-qtgui/lib/sink_c_impl.cc
+++ b/gr-qtgui/lib/sink_c_impl.cc
@@ -63,7 +63,8 @@ namespace gr {
d_center_freq(fc), d_bandwidth(bw), d_name(name),
d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
d_plottime(plottime), d_plotconst(plotconst),
- d_parent(parent)
+ d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -75,9 +76,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&sink_c_impl::handle_set_freq, this, _1));
d_main_gui = NULL;
@@ -328,8 +329,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/sink_c_impl.h b/gr-qtgui/lib/sink_c_impl.h
index 87ce7ad39e..95c549ba6c 100644
--- a/gr-qtgui/lib/sink_c_impl.h
+++ b/gr-qtgui/lib/sink_c_impl.h
@@ -48,6 +48,8 @@ namespace gr {
gr::high_res_timer_type d_last_update;
bool d_update_active;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/sink_f_impl.cc b/gr-qtgui/lib/sink_f_impl.cc
index 17a4f78db4..8487e78774 100644
--- a/gr-qtgui/lib/sink_f_impl.cc
+++ b/gr-qtgui/lib/sink_f_impl.cc
@@ -63,7 +63,8 @@ namespace gr {
d_center_freq(fc), d_bandwidth(bw), d_name(name),
d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
d_plottime(plottime), d_plotconst(plotconst),
- d_parent(parent)
+ d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -75,9 +76,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&sink_f_impl::handle_set_freq, this, _1));
d_main_gui = NULL;
@@ -323,8 +324,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/sink_f_impl.h b/gr-qtgui/lib/sink_f_impl.h
index 53494b9ccf..fb1bd420eb 100644
--- a/gr-qtgui/lib/sink_f_impl.h
+++ b/gr-qtgui/lib/sink_f_impl.h
@@ -46,6 +46,8 @@ namespace gr {
double d_bandwidth;
std::string d_name;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index 6fe06b74a0..a57e0574fe 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -53,7 +53,8 @@ namespace gr {
io_signature::make(0, nconnections, sizeof(gr_complex)),
io_signature::make(0, 0, 0)),
d_size(size), d_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name),
- d_nconnections(2*nconnections), d_parent(parent)
+ d_nconnections(2*nconnections), d_parent(parent),
+ d_tag_key(pmt::mp("tags"))
{
if(nconnections > 12)
throw std::runtime_error("time_sink_c only supports up to 12 inputs");
@@ -719,9 +720,9 @@ namespace gr {
// add tag info if it is present in metadata
if(pmt::is_dict(dict)){
- if(pmt::dict_has_key(dict, pmt::mp("tags"))){
+ if(pmt::dict_has_key(dict, d_tag_key)){
d_tags.clear();
- pmt::pmt_t tags = pmt::dict_ref(dict, pmt::mp("tags"), pmt::PMT_NIL);
+ pmt::pmt_t tags = pmt::dict_ref(dict, d_tag_key, pmt::PMT_NIL);
int len = pmt::length(tags);
for(int i=0; i<len; i++){
// get tag info from list
@@ -729,7 +730,7 @@ namespace gr {
int tagval = pmt::to_long(pmt::tuple_ref(tup,0));
pmt::pmt_t k = pmt::tuple_ref(tup,1);
pmt::pmt_t v = pmt::tuple_ref(tup,2);
-
+
// add the tag
t[0].push_back( gr::tag_t() );
t[0][t[0].size()-1].offset = tagval;
diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h
index ff938f8ea1..e62dc3c672 100644
--- a/gr-qtgui/lib/time_sink_c_impl.h
+++ b/gr-qtgui/lib/time_sink_c_impl.h
@@ -40,6 +40,8 @@ namespace gr {
std::string d_name;
int d_nconnections;
+ const pmt::pmt_t d_tag_key;
+
int d_index, d_start, d_end;
std::vector<gr_complex*> d_cbuffers;
std::vector<double*> d_buffers;
diff --git a/gr-qtgui/lib/vector_sink_f_impl.cc b/gr-qtgui/lib/vector_sink_f_impl.cc
index 6197da4949..a10ce18e77 100644
--- a/gr-qtgui/lib/vector_sink_f_impl.cc
+++ b/gr-qtgui/lib/vector_sink_f_impl.cc
@@ -77,8 +77,9 @@ namespace gr {
d_vecavg(1.0),
d_name(name),
d_nconnections(nconnections),
- d_msg_key("x"),
- d_parent(parent)
+ d_msg(pmt::mp("x")),
+ d_parent(parent),
+ d_port(pmt::mp(MSG_PORT_OUT_XVAL))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -90,7 +91,7 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp(MSG_PORT_OUT_XVAL));
+ message_port_register_out(d_port);
d_main_gui = NULL;
@@ -397,8 +398,8 @@ namespace gr {
if(d_main_gui->checkClicked()) {
double xval = d_main_gui->getClickedXVal();
message_port_pub(
- pmt::mp(MSG_PORT_OUT_XVAL),
- pmt::cons(pmt::mp(d_msg_key), pmt::from_double(xval))
+ d_port,
+ pmt::cons(d_msg, pmt::from_double(xval))
);
}
}
diff --git a/gr-qtgui/lib/vector_sink_f_impl.h b/gr-qtgui/lib/vector_sink_f_impl.h
index 12cf362fee..23ff1d8e94 100644
--- a/gr-qtgui/lib/vector_sink_f_impl.h
+++ b/gr-qtgui/lib/vector_sink_f_impl.h
@@ -46,7 +46,9 @@ namespace gr {
std::string d_name; //!< Initial title of the plot
int d_nconnections; //!< Number of connected streaming ports on input
- std::string d_msg_key; //!< Key of outgoing messages
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_msg; //< Key of outgoing messages
std::vector<double*> d_magbufs;
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index fbc655afba..dfde1a0026 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -60,7 +60,8 @@ namespace gr {
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_nrows(200), d_parent(parent)
+ d_nconnections(nconnections), d_nrows(200), d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -106,9 +107,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&waterfall_sink_c_impl::handle_set_freq, this, _1));
// setup PDU handling input port
@@ -485,8 +486,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h b/gr-qtgui/lib/waterfall_sink_c_impl.h
index 49766cd3dc..bd6baf552e 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -49,6 +49,8 @@ namespace gr {
int d_nconnections;
int d_nrows;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index fdb8fde686..546ad74826 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -60,7 +60,8 @@ namespace gr {
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
d_nconnections(nconnections), d_nrows(200),
- d_parent(parent)
+ d_parent(parent),
+ d_port(pmt::mp("freq"))
{
// Required now for Qt; argc must be greater than 0 and argv
// must have at least one valid character. Must be valid through
@@ -106,9 +107,9 @@ namespace gr {
// setup output message port to post frequency when display is
// double-clicked
- message_port_register_out(pmt::mp("freq"));
- message_port_register_in(pmt::mp("freq"));
- set_msg_handler(pmt::mp("freq"),
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
boost::bind(&waterfall_sink_f_impl::handle_set_freq, this, _1));
// setup PDU handling input port
@@ -493,8 +494,8 @@ namespace gr {
{
if(d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(pmt::mp("freq"),
- pmt::cons(pmt::mp("freq"),
+ message_port_pub(d_port,
+ pmt::cons(d_port,
pmt::from_double(freq)));
}
}
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h b/gr-qtgui/lib/waterfall_sink_f_impl.h
index db0f4239bc..1e5555db64 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -49,6 +49,8 @@ namespace gr {
int d_nconnections;
int d_nrows;
+ const pmt::pmt_t d_port;
+
bool d_shift;
fft::fft_complex *d_fft;