|
Boost Users : |
From: Michael Marcin (mmarcin_at_[hidden])
Date: 2007-04-25 14:33:06
Hello,
I have a new programmer on my team who has been brought on as an
optimization engineer. She has a lot more experience than I do but I fear
some of that experience may have left impressions that have stuck with her
for too long. On the first check in labeled spot optimizations there were
many things changed that disturbed me. One of them was changing a class
from essentially.
#include <boost/scoped_array.hpp>
class Context
{
public:
Context( unsigned int width, unsigned int height )
: m_buffer( new unsigned int[width*height] )
{
}
unsigned int* GetBuffer() { return m_buffer.get(); }
private:
boost::scoped_array<unsigned int> m_buffer;
};
to
class Context
{
public:
Context( unsigned int width, unsigned int height )
: m_buffer( new unsigned int[width*height] )
{
}
~Context()
{
delete m_buffer;
}
inline unsigned int* GetBuffer() { return m_buffer; }
private:
unsigned int* m_buffer;
};
First of all there is the defect of delete being called instead of delete[].
Other than that I was under the impression that there should be no
difference between the two other than the former being more descriptive (it
instantly tells me this is an array and the memory is owned by the instance
of this class).
Is this really an optimization?
Thanks,
Michael Marcin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net