From: eb Date: Wed, 15 Jul 2009 01:21:59 +0000 (+0000) Subject: pmt performance improvement: avoid some double type casting (c1256 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4eca9fb849d88274f57167fb8023772e5fe24624;p=debian%2Fgnuradio 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 --- diff --git a/pmt/src/lib/pmt.cc b/pmt/src/lib/pmt.cc index e854e275..aba06047 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(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(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(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