Mercurial > hg > octave-lyh
changeset 9556:948795dc1974
make a few Array methods inline
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 23 Aug 2009 22:00:03 +0200 |
parents | 76ecc571879e |
children | 3a1dd361f978 |
files | liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog |
diffstat | 3 files changed, 37 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -46,18 +46,6 @@ // all the derived classes. template <class T> -void -Array<T>::make_unique (void) -{ - if (rep->count > 1) - { - --rep->count; - rep = new ArrayRep (slice_data, slice_len, true); - slice_data = rep->data; - } -} - -template <class T> Array<T>::Array (const Array<T>& a, const dim_vector& dv) : rep (a.rep), dimensions (dv), slice_data (a.slice_data), slice_len (a.slice_len) @@ -70,33 +58,6 @@ } template <class T> -Array<T>::~Array (void) -{ - if (--rep->count <= 0) - delete rep; -} - -template <class T> -Array<T>& -Array<T>::operator = (const Array<T>& a) -{ - if (this != &a) - { - if (--rep->count <= 0) - delete rep; - - rep = a.rep; - rep->count++; - - dimensions = a.dimensions; - slice_data = a.slice_data; - slice_len = a.slice_len; - } - - return *this; -} - -template <class T> void Array<T>::fill (const T& val) {
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -98,7 +98,15 @@ public: - void make_unique (void); + void make_unique (void) + { + if (rep->count > 1) + { + --rep->count; + rep = new ArrayRep (slice_data, slice_len, true); + slice_data = rep->data; + } + } typedef T element_type; @@ -233,9 +241,29 @@ Array (const Array<T>& a, const dim_vector& dv); - virtual ~Array (void); + ~Array (void) + { + if (--rep->count <= 0) + delete rep; + } - Array<T>& operator = (const Array<T>& a); + Array<T>& operator = (const Array<T>& a) + { + if (this != &a) + { + if (--rep->count <= 0) + delete rep; + + rep = a.rep; + rep->count++; + + dimensions = a.dimensions; + slice_data = a.slice_data; + slice_len = a.slice_len; + } + + return *this; + } void fill (const T& val); void clear (void);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2009-08-23 Jaroslav Hajek <highegg@gmail.com> + + * Array.h (Array::make_unique, Array::~Array, Array::operator =): + Move here to allow inlining. + * Array.cc: Remove from here. + 2009-08-20 Jaroslav Hajek <highegg@gmail.com> * mx-inlines.cc (logical_value): New overloaded template.