diff options
author | eb | 2009-07-15 01:21:59 +0000 |
---|---|---|
committer | eb | 2009-07-15 01:21:59 +0000 |
commit | 4eca9fb849d88274f57167fb8023772e5fe24624 (patch) | |
tree | b29da22cb00b01e6123925531ba851702bdab459 /pmt/src | |
parent | 962e22878b5ef6aa3280fafefb2732db84a69258 (diff) | |
download | gnuradio-4eca9fb849d88274f57167fb8023772e5fe24624.tar.gz gnuradio-4eca9fb849d88274f57167fb8023772e5fe24624.tar.bz2 gnuradio-4eca9fb849d88274f57167fb8023772e5fe24624.zip |
pmt performance improvement: avoid some double type casting (c1256
from Stefan BrĂ¼ns)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11437 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'pmt/src')
-rw-r--r-- | pmt/src/lib/pmt.cc | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/pmt/src/lib/pmt.cc b/pmt/src/lib/pmt.cc index e854e2756..aba060474 100644 --- a/pmt/src/lib/pmt.cc +++ b/pmt/src/lib/pmt.cc @@ -292,8 +292,9 @@ pmt_from_long(long x) long pmt_to_long(pmt_t x) { - if (x->is_integer()) - return _integer(x)->value(); + pmt_integer* i = dynamic_cast<pmt_integer*>(x.get()); + if ( i ) + return i->value(); throw pmt_wrong_type("pmt_to_long", x); } @@ -386,8 +387,9 @@ pmt_cons(pmt_t x, pmt_t y) pmt_t pmt_car(pmt_t pair) { - if (pair->is_pair()) - return _pair(pair)->car(); + pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get()); + if ( p ) + return p->car(); throw pmt_wrong_type("pmt_car", pair); } @@ -395,8 +397,9 @@ pmt_car(pmt_t pair) pmt_t pmt_cdr(pmt_t pair) { - if (pair->is_pair()) - return _pair(pair)->cdr(); + pmt_pair* p = dynamic_cast<pmt_pair*>(pair.get()); + if ( p ) + return p->cdr(); throw pmt_wrong_type("pmt_cdr", pair); } @@ -585,28 +588,31 @@ pmt_make_dict() void pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value) { - if (!dict->is_dict()) + pmt_dict* d = _dict(dict); + if (!d) throw pmt_wrong_type("pmt_dict_set", dict); - _dict(dict)->set(key, value); + d->set(key, value); } bool pmt_dict_has_key(pmt_t dict, pmt_t key) { - if (!dict->is_dict()) + pmt_dict* d = _dict(dict); + if (!d) throw pmt_wrong_type("pmt_dict_has_key", dict); - return _dict(dict)->has_key(key); + return d->has_key(key); } pmt_t pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found) { - if (!dict->is_dict()) + pmt_dict* d = _dict(dict); + if (!d) throw pmt_wrong_type("pmt_dict_ref", dict); - return _dict(dict)->ref(key, not_found); + return d->ref(key, not_found); } pmt_t |