changeset 9007:7e31df9a0334

simplify double->int conversion in indexing
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 23 Mar 2009 14:23:48 +0100
parents 979d0492ff40
children 7a7cf569528d
files liboctave/ChangeLog liboctave/idx-vector.cc
diffstat 2 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-23  Jaroslav Hajek  <highegg@gmail.com>
+
+	* idx-vector.cc (convert_index(double,...)): Simplify.
+
 2009-03-21  Jaroslav Hajek  <highegg@gmail.com>
 
 	* Array-d.cc: lo_ieee_isnan -> xisnan.
--- a/liboctave/idx-vector.cc
+++ b/liboctave/idx-vector.cc
@@ -182,18 +182,9 @@
 inline octave_idx_type
 convert_index (double x, bool& conv_error, octave_idx_type& ext)
 {
-  octave_idx_type i;
-  if (xisnan (x) || xisinf (x))
-    {
-      i = 0;
-      conv_error = true;
-    }
-  else
-    {
-      i = static_cast<octave_idx_type> (x);
-      if (static_cast<double> (i) != x)
-        conv_error = true;
-    }
+  octave_idx_type i = static_cast<octave_idx_type> (x);
+  if (static_cast<double> (i) != x)
+    conv_error = true;
 
   return convert_index (i, conv_error, ext);
 }