diff options
author | Marcus Müller <mueller@kit.edu> | 2018-02-20 13:11:06 +0100 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-02-23 19:06:50 +0100 |
commit | 8508461a2358a183fc555568041faeebffa73f59 (patch) | |
tree | 859dfe5f2e97b120fd7ec2043e4bdafc819982ab | |
parent | 9b63bb4f4a52c172ea8f4ebf8e0577cf101da69c (diff) |
digital: 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.
-rw-r--r-- | gr-digital/lib/hdlc_deframer_bp_impl.cc | 7 | ||||
-rw-r--r-- | gr-digital/lib/hdlc_deframer_bp_impl.h | 2 | ||||
-rw-r--r-- | gr-digital/lib/packet_headerparser_b_impl.cc | 11 | ||||
-rw-r--r-- | gr-digital/lib/packet_headerparser_b_impl.h | 2 |
4 files changed, 13 insertions, 9 deletions
diff --git a/gr-digital/lib/hdlc_deframer_bp_impl.cc b/gr-digital/lib/hdlc_deframer_bp_impl.cc index 976d14784d..65352bb8be 100644 --- a/gr-digital/lib/hdlc_deframer_bp_impl.cc +++ b/gr-digital/lib/hdlc_deframer_bp_impl.cc @@ -48,10 +48,11 @@ namespace gr { gr::io_signature::make(1, 1, sizeof(unsigned char)), gr::io_signature::make(0, 0, 0)), d_length_min(length_min), - d_length_max(length_max) + d_length_max(length_max), + d_port(pmt::mp("out")) { set_output_multiple(length_max*2); - message_port_register_out(pmt::mp("out")); + message_port_register_out(d_port); d_bytectr=0; d_bitctr=0; d_ones=0; @@ -101,7 +102,7 @@ namespace gr { if (crc==calc_crc) { pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL, pmt::make_blob(d_pktbuf, len))); - message_port_pub(pmt::mp("out"), pdu); + message_port_pub(d_port, pdu); } else { } diff --git a/gr-digital/lib/hdlc_deframer_bp_impl.h b/gr-digital/lib/hdlc_deframer_bp_impl.h index d29d9fcc3e..962805f78a 100644 --- a/gr-digital/lib/hdlc_deframer_bp_impl.h +++ b/gr-digital/lib/hdlc_deframer_bp_impl.h @@ -38,6 +38,8 @@ namespace gr { size_t d_bitctr; unsigned char *d_pktbuf; + const pmt::pmt_t d_port; + unsigned int crc_ccitt(unsigned char *data, size_t len); public: diff --git a/gr-digital/lib/packet_headerparser_b_impl.cc b/gr-digital/lib/packet_headerparser_b_impl.cc index f7593d5fb2..c461bd8160 100644 --- a/gr-digital/lib/packet_headerparser_b_impl.cc +++ b/gr-digital/lib/packet_headerparser_b_impl.cc @@ -27,8 +27,6 @@ #include <gnuradio/io_signature.h> #include "packet_headerparser_b_impl.h" -#define msg_port_id pmt::mp("header_data") - namespace gr { namespace digital { @@ -51,9 +49,10 @@ namespace gr { : sync_block("packet_headerparser_b", io_signature::make(1, 1, sizeof (unsigned char)), io_signature::make(0, 0, 0)), - d_header_formatter(header_formatter) + d_header_formatter(header_formatter), + d_port(pmt::mp("header_data")) { - message_port_register_out(msg_port_id); + message_port_register_out(d_port); set_output_multiple(header_formatter->header_len()); } @@ -81,13 +80,13 @@ namespace gr { if (!d_header_formatter->header_parser(in, tags)) { GR_LOG_INFO(d_logger, boost::format("Detected an invalid packet at item %1%") % nitems_read(0)); - message_port_pub(msg_port_id, pmt::PMT_F); + message_port_pub(d_port, pmt::PMT_F); } else { pmt::pmt_t dict(pmt::make_dict()); for (unsigned i = 0; i < tags.size(); i++) { dict = pmt::dict_add(dict, tags[i].key, tags[i].value); } - message_port_pub(msg_port_id, dict); + message_port_pub(d_port, dict); } return d_header_formatter->header_len(); diff --git a/gr-digital/lib/packet_headerparser_b_impl.h b/gr-digital/lib/packet_headerparser_b_impl.h index 41641eda4d..dcfb83a806 100644 --- a/gr-digital/lib/packet_headerparser_b_impl.h +++ b/gr-digital/lib/packet_headerparser_b_impl.h @@ -32,6 +32,8 @@ namespace gr { private: packet_header_default::sptr d_header_formatter; + const pmt::pmt_t d_port; + public: packet_headerparser_b_impl(const gr::digital::packet_header_default::sptr &header_formatter); ~packet_headerparser_b_impl(); |