Mercurial > hg > octave-lyh
changeset 13990:c9a0e5343cd8
use static storage for array nil rep instead of allocating it with new
* Array.h (Array<T>::ArrayRep::nil_rep): Use static object for nil rep
instead of allocating it with new.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 04 Dec 2011 03:38:45 -0500 |
parents | b4d399c975de |
children | 051a8f94b6f8 |
files | liboctave/Array.h |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -156,10 +156,12 @@ typename Array<T>::ArrayRep *nil_rep (void) const { - static typename Array<T>::ArrayRep *nr - = new typename Array<T>::ArrayRep (); + // NR was originally allocated with new, but that does not seem + // to be necessary since it will never be deleted. So just use + // a static object instead. - return nr; + static typename Array<T>::ArrayRep nr; + return &nr; } public: