[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Avoid double memory initilization in PMT unified vect
From: |
Stefan Brüns |
Subject: |
[Discuss-gnuradio] Avoid double memory initilization in PMT unified vectors |
Date: |
Tue, 07 Oct 2008 19:26:08 +0200 |
User-agent: |
KMail/1.9.9 |
Hi,
in PMT, there is code like:
pmt_u8vector::pmt_u8vector(size_t k, uint8_t fill)
: d_v(k)
{
for (size_t i = 0; i < k; i++)
d_v[i] = fill;
}
As std::vector initializes the memory by itself when called with an size
argument in the constructor, the memory is initialized twice.
A faster version with the same result is:
pmt_u8vector::pmt_u8vector(size_t k, uint8_t fill)
: d_v(k, fill)
{}
Same is true for the other data types.
Another question:
Why are the classes for the different types written "by hand", and not using
templates, eg:
template <typename T>
class pmt_uniform_vector
{
...
}
typedef pmt_uniform_vector< uint8_t > pmt_u8vector;
Stefan
--
Stefan Brüns / Bergstraße 21 / 52062 Aachen
mailto:lurch at gmx.li http://www.kawo1.rwth-aachen.de/~lurchi/
phone: +49 241 53809034 mobile: +49 151 50412019
- [Discuss-gnuradio] Avoid double memory initilization in PMT unified vectors,
Stefan Brüns <=