diff libinterp/octave-value/ov-bool-mat.cc @ 20962:3aa293be0e8d

maint: Invert simple conditionals in if/else/error paradigm. Invert conditional in if statement and place error next to if. Delete else, and decrease code indent by 4. * cellfun.cc, data.cc, debug.cc, dirfns.cc, dynamic-ld.cc, file-io.cc, gl2ps-renderer.cc, graphics.cc, graphics.in.h, hex2num.cc, load-save.cc, ls-mat-ascii.cc, ls-oct-text.cc, oct-hist.cc, oct-lvalue.cc, oct-map.cc, toplev.cc, __init_fltk__.cc, ov-base-int.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-cx-mat.cc, ov-fcn-handle.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-oncleanup.cc, ov-re-mat.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc, ov.cc, pt-arg-list.cc, pt-assign.cc, pt-colon.cc, pt-eval.cc, pt-exp.cc: Invert conditional in if statement and place error next to if. Delete else, and decrease code indent by 4.
author Rik <rik@octave.org>
date Tue, 22 Dec 2015 10:29:22 -0800
parents 850e3d2533d4
children 0963ed389012
line wrap: on
line diff
--- a/libinterp/octave-value/ov-bool-mat.cc	Tue Dec 22 07:43:44 2015 -0500
+++ b/libinterp/octave-value/ov-bool-mat.cc	Tue Dec 22 10:29:22 2015 -0800
@@ -225,84 +225,76 @@
   std::string kw;
   octave_idx_type val = 0;
 
-  if (extract_keyword (is, keywords, kw, val, true))
-    {
-      if (kw == "ndims")
-        {
-          int mdims = static_cast<int> (val);
+  if (! extract_keyword (is, keywords, kw, val, true))
+    error ("load: failed to extract number of rows and columns");
 
-          if (mdims >= 0)
-            {
-              dim_vector dv;
-              dv.resize (mdims);
-
-              for (int i = 0; i < mdims; i++)
-                is >> dv(i);
+  if (kw == "ndims")
+    {
+      int mdims = static_cast<int> (val);
 
-              if (is)
-                {
-                  boolNDArray btmp (dv);
+      if (mdims >= 0)
+        {
+          dim_vector dv;
+          dv.resize (mdims);
 
-                  if (btmp.is_empty ())
-                    matrix = btmp;
-                  else
-                    {
-                      NDArray tmp(dv);
-                      is >> tmp;
+          for (int i = 0; i < mdims; i++)
+            is >> dv(i);
 
-                      if (is)
-                        {
-                          for (octave_idx_type i = 0; i < btmp.numel (); i++)
-                            btmp.elem (i) = (tmp.elem (i) != 0.);
+          if (! is)
+            error ("load: failed to extract dimensions");
 
-                          matrix = btmp;
-                        }
-                      else
-                        error ("load: failed to load matrix constant");
-                    }
-                }
-              else
-                error ("load: failed to extract dimensions");
-            }
+          boolNDArray btmp (dv);
+
+          if (btmp.is_empty ())
+            matrix = btmp;
           else
-            error ("load: failed to extract number of dimensions");
-        }
-      else if (kw == "rows")
-        {
-          octave_idx_type nr = val;
-          octave_idx_type nc = 0;
-
-          if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
             {
-              if (nr > 0 && nc > 0)
-                {
-                  Matrix tmp (nr, nc);
-                  is >> tmp;
-                  if (is)
-                    {
-                      boolMatrix btmp (nr, nc);
-                      for (octave_idx_type j = 0; j < nc; j++)
-                        for (octave_idx_type i = 0; i < nr; i++)
-                          btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
+              NDArray tmp(dv);
+              is >> tmp;
+
+              if (! is)
+                error ("load: failed to load matrix constant");
 
-                      matrix = btmp;
-                    }
-                  else
-                    error ("load: failed to load matrix constant");
-                }
-              else if (nr == 0 || nc == 0)
-                matrix = boolMatrix (nr, nc);
-              else
-                panic_impossible ();
+              for (octave_idx_type i = 0; i < btmp.numel (); i++)
+                btmp.elem (i) = (tmp.elem (i) != 0.);
+
+              matrix = btmp;
             }
-          else
-            error ("load: failed to extract number of rows and columns");
         }
       else
-        panic_impossible ();
+        error ("load: failed to extract number of dimensions");
+    }
+  else if (kw == "rows")
+    {
+      octave_idx_type nr = val;
+      octave_idx_type nc = 0;
+
+      if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
+        {
+          if (nr > 0 && nc > 0)
+            {
+              Matrix tmp (nr, nc);
+              is >> tmp;
+              if (! is)
+                error ("load: failed to load matrix constant");
+
+              boolMatrix btmp (nr, nc);
+              for (octave_idx_type j = 0; j < nc; j++)
+                for (octave_idx_type i = 0; i < nr; i++)
+                  btmp.elem (i,j) = (tmp.elem (i, j) != 0.);
+
+              matrix = btmp;
+            }
+          else if (nr == 0 || nc == 0)
+            matrix = boolMatrix (nr, nc);
+          else
+            panic_impossible ();
+        }
+      else
+        error ("load: failed to extract number of rows and columns");
     }
   else
-    error ("load: failed to extract number of rows and columns");
+    panic_impossible ();
 
   return success;
 }