Quote Originally Posted by Bornish
Hmm, usually I agree with Paul...
What would be the worst case scenario? Having to allocate large quantities of objects with very short lifetime. How to most effectively obtain that? Reuse allocations!!!
That is not really the example I'm referring to.

What I'm refering to are the classes that persons create that attempt to do their own memory resizing. For example:
Code:
class foo
{
    char *ptr;
    public:
            void resize(unsigned int num)
            {
                 char *temp = new char [num];
                 delete [] ptr;
                 ptr = temp;
            }
};
How many times have you seen code written like this? In this case, it is a simple char*, but in other cases it could be any object. Replacing the naive version of resize() with a vector<char> and calling vector::resize() is defacto faster, since vector.resize() doesn't reallocate if it doesn't have to.

Regards,

Paul McKenzie