[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11437 - gnuradio/trunk/pmt/src/lib
From: |
eb |
Subject: |
[Commit-gnuradio] r11437 - gnuradio/trunk/pmt/src/lib |
Date: |
Tue, 14 Jul 2009 19:22:00 -0600 (MDT) |
Author: eb
Date: 2009-07-14 19:21:59 -0600 (Tue, 14 Jul 2009)
New Revision: 11437
Modified:
gnuradio/trunk/pmt/src/lib/pmt.cc
Log:
pmt performance improvement: avoid some double type casting (c1256
from Stefan Br?\195?\188ns)
Modified: gnuradio/trunk/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/trunk/pmt/src/lib/pmt.cc 2009-07-15 01:18:56 UTC (rev 11436)
+++ gnuradio/trunk/pmt/src/lib/pmt.cc 2009-07-15 01:21:59 UTC (rev 11437)
@@ -292,8 +292,9 @@
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_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_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 @@
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11437 - gnuradio/trunk/pmt/src/lib,
eb <=