changeset 2108:2b67abb63030

[project @ 1996-04-30 10:44:17 by jwe]
author jwe
date Tue, 30 Apr 1996 10:44:44 +0000
parents 2eec34fc1aca
children 356f70c8fcbd
files configure.in liboctave/Array.h
diffstat 2 files changed, 37 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Tue Apr 30 10:15:50 1996 +0000
+++ b/configure.in	Tue Apr 30 10:44:44 1996 +0000
@@ -20,7 +20,7 @@
 ### along with Octave; see the file COPYING.  If not, write to the Free
 ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-AC_REVISION($Revision: 1.194 $)
+AC_REVISION($Revision: 1.195 $)
 AC_PREREQ(2.9)
 AC_INIT(src/octave.cc)
 AC_CONFIG_HEADER(config.h)
@@ -183,6 +183,18 @@
 AC_SUBST(LIBREADLINE)
 AC_SUBST(READLINE_DIR)
 
+### By default, Octave's internal array and matrix classes do bounds
+### checking on element references.  This slows some operations down a
+### bit, so give the user the option of disabling it.
+
+BOUNDS_CHECKING=true
+AC_ARG_ENABLE(bounds-check,
+  [  --enable-bounds-check   for internal array classes (default is yes)],
+  [if test "$enableval" = no; then BOUNDS_CHECKING=false; fi], [])
+if $BOUNDS_CHECKING; then
+  AC_DEFINE(BOUNDS_CHECKING, 1)
+fi
+
 ### See which C++ compiler to use (we expect to find g++).
 
 EXTERN_CXXFLAGS="$CXXFLAGS"
@@ -327,7 +339,7 @@
 ### shl_load/shl_findsym (HP/UX only?).
 
 AC_ARG_ENABLE(shl,
-  [  --enable-shl            use shl_load/shl_findsym for dynamic linking (HP only?)],
+  [  --enable-shl            use shl_load/shl_findsym for dynamic linking (HP only)],
   [if test $enableval = no; then WITH_SHL=no;
    elif test $enableval = yes; then WITH_SHL=yes;
    else WITH_SHL=maybe; fi],
@@ -1058,6 +1070,7 @@
   Default pager:        $DEFAULT_PAGER
   gnuplot:              $GNUPLOT_BINARY
 
+  Do internal array bounds checking:       $BOUNDS_CHECKING
   Build shared libraries:                  $SHARED_LIBS
   Minimal kernel option:                   $OCTAVE_LITE
   Dynamic Linking (dlopen/dlsym):          $WITH_DL
--- a/liboctave/Array.h	Tue Apr 30 10:15:50 1996 +0000
+++ b/liboctave/Array.h	Tue Apr 30 10:44:44 1996 +0000
@@ -164,16 +164,15 @@
   int capacity (void) const { return rep->length (); }
   int length (void) const { return rep->length (); }
 
+  // No checking, even for multiple references, ever.
+
+  T& xelem (int n) { return rep->elem (n); }
+  T xelem (int n) const { return rep->elem (n); }
+
   // XXX FIXME XXX -- would be nice to fix this so that we don't
   // unnecessarily force a copy, but that is not so easy, and I see no
   // clean way to do it.
 
-  T& elem (int n)
-    {
-      make_unique ();
-      return rep->elem (n);
-    }
-
   T& Array<T>::checkelem (int n)
     {
       if (n < 0 || n >= rep->length ())
@@ -183,35 +182,39 @@
 	  return foo;
 	}
       else
-	return elem (n);
+	{
+	  make_unique ();
+	  return xelem (n);
+	}
     }
 
-#if defined (NO_BOUNDS_CHECKING)
-  T& operator () (int n) { return elem (n); }
+#if defined (BOUNDS_CHECKING)
+  T& elem (int n) { return checkelem (n); }
 #else
-  T& operator () (int n) { return checkelem (n); }
+  T& elem (int n)
+    {
+      make_unique ();
+      return xelem ();
+    }
 #endif
 
-  T Array<T>::elem (int n) const { return rep->elem (n); }
+  T& operator () (int n) { return elem (n); }
 
   T Array<T>::checkelem (int n) const
     {
       if (n < 0 || n >= rep->length ())
 	return range_error ();
       else
-	return elem (n);
+	return xelem (n);
     }
 
-#if defined (NO_BOUNDS_CHECKING)
-  T Array<T>::operator () (int n) const { return elem (n); }
+#if defined (BOUNDS_CHECKING)
+  T Array<T>::elem (int n) const { return checkelem (n); }
 #else
-  T Array<T>::operator () (int n) const { return checkelem (n); }
+  T Array<T>::elem (int n) const { return xelem (n); }
 #endif
 
-  // No checking, even for multiple references, ever.
-
-  T& xelem (int n) { return rep->elem (n); }
-  T xelem (int n) const { return rep->elem (n); }
+  T Array<T>::operator () (int n) const { return elem (n); }
 
   void resize (int n);
   void resize (int n, const T& val);