# HG changeset patch # User Jaroslav Hajek # Date 1275388456 -7200 # Node ID e3064439d6b487f8f6bfca35286620cbdb32e20a # Parent b17a966099edd2355fb63e3d9cad576dfaccbedb new Array method for internal use diff --git a/liboctave/Array.cc b/liboctave/Array.cc --- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2571,6 +2571,16 @@ } template +bool Array::optimize_dimensions (const dim_vector& dv) +{ + bool retval = dimensions == dv; + if (retval) + dimensions = dv; + + return retval; +} + +template void Array::instantiation_guard () { // This guards against accidental implicit instantiations. diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -622,6 +622,11 @@ template friend class Array; + // Returns true if this->dims () == dv, and if so, replaces this->dimensions + // by a shallow copy of dv. This is useful for maintaining several arrays with + // supposedly equal dimensions (e.g. structs in the interpreter). + bool optimize_dimensions (const dim_vector& dv); + private: static void instantiation_guard (); }; diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-06-01 Jaroslav Hajek + + * Array.cc (Array::optimize_dimensions): New method. + * Array.h: Declare it. + 2010-06-01 Jaroslav Hajek * Array.cc (Array::maybe_delete_dims): Remove method (makes no