From 4eca9fb849d88274f57167fb8023772e5fe24624 Mon Sep 17 00:00:00 2001 From: eb Date: Wed, 15 Jul 2009 01:21:59 +0000 Subject: [PATCH] =?utf8?q?pmt=20performance=20improvement:=20avoid=20some?= =?utf8?q?=20double=20type=20casting=20(c1256=20from=20Stefan=20Br=C3=BCns?= =?utf8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11437 221aa14e-8319-0410-a670-987f0aec2ac5 --- pmt/src/lib/pmt.cc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) 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 -- 2.47.2