changeset 21885:0806871e3e1e

maint: Prefer is_empty() rather than "length () == 0". * QtHandlesUtils.cc, octave-qt-link.cc, dasrt.cc, data.cc, debug.cc, error.cc, input.cc, jit-typeinfo.cc, ls-mat5.cc, lsode.cc, oct-stream.cc, variables.cc, ov-base-diag.cc, ov-bool-sparse.cc, ov-classdef.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-flt-re-mat.cc, ov-intx.h, ov-perm.cc, ov-re-mat.cc, ov-re-sparse.cc, pt.cc, file-ops.cc, url-transfer.cc: Prefer is_empty() rather than "length () == 0".
author Rik <rik@octave.org>
date Mon, 13 Jun 2016 09:18:03 -0700
parents e8a8cb1a7258
children 4c0c6f48bdc7
files libgui/graphics/QtHandlesUtils.cc libgui/src/octave-qt-link.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/data.cc libinterp/corefcn/debug.cc libinterp/corefcn/error.cc libinterp/corefcn/input.cc libinterp/corefcn/jit-typeinfo.cc libinterp/corefcn/ls-mat5.cc libinterp/corefcn/lsode.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/variables.cc libinterp/octave-value/ov-base-diag.cc libinterp/octave-value/ov-bool-sparse.cc libinterp/octave-value/ov-classdef.cc libinterp/octave-value/ov-cx-sparse.cc libinterp/octave-value/ov-fcn-handle.cc libinterp/octave-value/ov-flt-re-mat.cc libinterp/octave-value/ov-intx.h libinterp/octave-value/ov-perm.cc libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-re-sparse.cc libinterp/parse-tree/pt.cc liboctave/system/file-ops.cc liboctave/util/url-transfer.cc
diffstat 25 files changed, 38 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/QtHandlesUtils.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libgui/graphics/QtHandlesUtils.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -85,13 +85,13 @@
 {
   QStringList tmp = l;
 
-  // dont get any empty lines from end of the list
-  while ((tmp.length () > 0) && (tmp.last ().length () == 0))
+  // don't get any empty lines from end of the list
+  while ((tmp.length () > 0) && tmp.last ().isEmpty ())
     {
       tmp.removeLast ();
     }
-  // no strings will be a a 1x1 cell with empty string
-  if (tmp.length () == 0)
+  // no strings converts to a 1x1 cell with empty string
+  if (tmp.isEmpty ())
     tmp += "";
 
   Cell v(toStringVector (tmp));
--- a/libgui/src/octave-qt-link.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libgui/src/octave-qt-link.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -255,7 +255,7 @@
       name.replace (QRegExp ("\\(.*\\)"), "");
       ext.replace (";", " ");
 
-      if (name.length () == 0)
+      if (name.isEmpty ())
         {
           // No name field.  Build one from the extensions.
           name = ext.toUpper () + " Files";
--- a/libinterp/corefcn/dasrt.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/dasrt.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -84,7 +84,7 @@
           err_user_supplied_eval (e, "dasrt");
         }
 
-      if (tmp.length () == 0 || ! tmp(0).is_defined ())
+      if (tmp.empty () || ! tmp(0).is_defined ())
         err_user_supplied_eval ("dasrt");
 
       if (! warned_fcn_imaginary && tmp(0).is_complex_type ())
@@ -125,7 +125,7 @@
           err_user_supplied_eval (e, "dasrt");
         }
 
-      if (tmp.length () == 0 || ! tmp(0).is_defined ())
+      if (tmp.empty () || ! tmp(0).is_defined ())
         err_user_supplied_eval ("dasrt");
 
       if (! warned_cf_imaginary && tmp(0).is_complex_type ())
--- a/libinterp/corefcn/data.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/data.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -1815,7 +1815,7 @@
                  cname.c_str ());
         }
 
-      if (result.length () == 0)
+      if (result.empty ())
         error ("conversion from %s to %s failed", dtype.c_str (),
                cname.c_str ());
 
@@ -1843,7 +1843,7 @@
                  cname.c_str ());
         }
 
-      if (result.length () == 0)
+      if (result.empty ())
         error ("%s constructor failed for %s argument", dtype.c_str (),
                cname.c_str ());
 
@@ -1879,7 +1879,7 @@
           error (e, "%s/%s method failed", dtype.c_str (), cattype.c_str ());
         }
 
-      if (tmp2.length () == 0)
+      if (tmp2.empty ())
         error ("%s/%s method did not return a value", dtype.c_str (),
                cattype.c_str ());
 
--- a/libinterp/corefcn/debug.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/debug.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -1134,7 +1134,7 @@
                 }
             }
         }
-      if (mv.numel () == 0)
+      if (mv.is_empty ())
         {
           // no changes requested.  Occurs if "errs" non-empty but "bkpt" empty
         }
--- a/libinterp/corefcn/error.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/error.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -1893,7 +1893,7 @@
 
           if (new_err.contains ("stack"))
             {
-              if (new_err.getfield ("stack").numel () == 0)
+              if (new_err.getfield ("stack").is_empty ())
                 initialize_stack = true;
               else
                 {
--- a/libinterp/corefcn/input.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/input.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -751,7 +751,7 @@
 
       retval = eval_string (input_buf, true, parse_status, nargout);
 
-      if (! Vdebugging && retval.length () == 0)
+      if (! Vdebugging && retval.empty ())
         retval(0) = Matrix ();
     }
 
--- a/libinterp/corefcn/jit-typeinfo.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/jit-typeinfo.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -469,7 +469,7 @@
       return ret;
     }
 
-  if (! (ovl.length () == 0
+  if (! (ovl.empty () 
          || (ovl.length () == 1 && ovl.xelem (0).is_undefined ())))
     err_bad_result ();
 
--- a/libinterp/corefcn/ls-mat5.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/ls-mat5.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -854,7 +854,7 @@
 
         if (ftype == "simple" || ftype == "scopedfunction")
           {
-            if (fpath.length () == 0)
+            if (fpath.empty ())
               // We have a builtin function
               tc = make_fcn_handle (fname);
             else
--- a/libinterp/corefcn/lsode.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/lsode.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -81,7 +81,7 @@
           err_user_supplied_eval (e, "lsode");
         }
 
-      if (tmp.length () == 0 || ! tmp(0).is_defined ())
+      if (tmp.empty () || ! tmp(0).is_defined ())
         err_user_supplied_eval ("lsode");
 
       if (! warned_fcn_imaginary && tmp(0).is_complex_type ())
@@ -121,7 +121,7 @@
           err_user_supplied_eval (e, "lsode");
         }
 
-      if (tmp.length () == 0 || ! tmp(0).is_defined ())
+      if (tmp.empty () || ! tmp(0).is_defined ())
         err_user_supplied_eval ("lsode");
 
       if (! warned_jac_imaginary && tmp(0).is_complex_type ())
--- a/libinterp/corefcn/oct-stream.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/oct-stream.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -3150,7 +3150,7 @@
 textscan::scan_string (delimited_stream& is, const textscan_format_elt& fmt,
                        std::string& val) const
 {
-  if (delim_list.numel () == 0)
+  if (delim_list.is_empty ())
     {
       unsigned int i = 0;
       unsigned int width = fmt.width;
--- a/libinterp/corefcn/variables.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/corefcn/variables.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -1810,7 +1810,7 @@
     }
   else if (! (symbol_stats.empty () && symbol_names.empty ()))
     {
-      if (msg.length () == 0)
+      if (msg.empty ())
         if (global_only)
           octave_stdout << "Global variables:\n\n";
         else
--- a/libinterp/octave-value/ov-base-diag.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-base-diag.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -300,7 +300,7 @@
     warn_implicit_conversion ("Octave:imag-to-real",
                               "complex matrix", "real scalar");
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion (type_name (), "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
--- a/libinterp/octave-value/ov-bool-sparse.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -102,7 +102,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("bool sparse matrix", "real scalar");
 
   if (numel () > 1)
--- a/libinterp/octave-value/ov-classdef.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-classdef.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -912,7 +912,7 @@
 
           retlist = meth.execute (args, 1, true, "subsasgn");
 
-          if (retlist.length () == 0)
+          if (retlist.empty ())
             error ("overloaded method `subsasgn' did not return any value");
 
           retval = retlist(0);
--- a/libinterp/octave-value/ov-cx-sparse.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -113,7 +113,7 @@
                               "complex sparse matrix", "real scalar");
 
   // FIXME: maybe this should be a function, valid_as_scalar()
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("complex sparse matrix", "real scalar");
 
   if (numel () > 1)
@@ -147,7 +147,7 @@
   Complex retval (tmp, tmp);
 
   // FIXME: maybe this should be a function, valid_as_scalar()
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("complex sparse matrix", "real scalar");
 
   if (numel () > 1)
--- a/libinterp/octave-value/ov-fcn-handle.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -393,14 +393,14 @@
 
   std::streampos pos = is.tellg ();
   std::string octaveroot = extract_keyword (is, "octaveroot", true);
-  if (octaveroot.length () == 0)
+  if (octaveroot.empty ())
     {
       is.seekg (pos);
       is.clear ();
     }
   pos = is.tellg ();
   std::string fpath = extract_keyword (is, "path", true);
-  if (fpath.length () == 0)
+  if (fpath.empty ())
     {
       is.seekg (pos);
       is.clear ();
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -91,7 +91,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("real matrix", "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
@@ -107,7 +107,7 @@
 {
   float retval = lo_ieee_float_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("real matrix", "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
--- a/libinterp/octave-value/ov-intx.h	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-intx.h	Mon Jun 13 09:18:03 2016 -0700
@@ -109,7 +109,7 @@
   {
     double retval = lo_ieee_nan_value ();
 
-    if (numel () == 0)
+    if (is_empty ())
       err_invalid_conversion (type_name (), "real scalar");
 
     warn_implicit_conversion ("Octave:array-to-scalar",
@@ -125,7 +125,7 @@
   {
     float retval = lo_ieee_float_nan_value ();
 
-    if (numel () == 0)
+    if (is_empty ())
       err_invalid_conversion (type_name (), "real scalar");
 
     warn_implicit_conversion ("Octave:array-to-scalar",
--- a/libinterp/octave-value/ov-perm.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-perm.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -142,7 +142,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion (type_name (), "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
@@ -158,7 +158,7 @@
 {
   float retval = lo_ieee_float_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion (type_name (), "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
--- a/libinterp/octave-value/ov-re-mat.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-re-mat.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -106,7 +106,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("real matrix", "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
@@ -122,7 +122,7 @@
 {
   float retval = lo_ieee_float_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("real matrix", "real scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
--- a/libinterp/octave-value/ov-re-sparse.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/octave-value/ov-re-sparse.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -97,7 +97,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  if (numel () == 0)
+  if (is_empty ())
     err_invalid_conversion ("real sparse matrix", "real scalar");
 
   if (numel () > 1)
--- a/libinterp/parse-tree/pt.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/libinterp/parse-tree/pt.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -59,7 +59,7 @@
   bool retval;
   if (bp == 0)
     retval = false;
-  else if (bp->length () == 0)     // empty condition always met
+  else if (bp->empty ())     // empty condition always met
     retval = true;
   else
     {
--- a/liboctave/system/file-ops.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/liboctave/system/file-ops.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -274,7 +274,7 @@
           // If we don't have a failure hook, or if the failure hook did not
           // expand the tilde, return a copy of what we were passed.
 
-          if (dirname.length () == 0)
+          if (dirname.empty ())
             dirname = filename;
         }
       else
--- a/liboctave/util/url-transfer.cc	Mon Jun 13 10:55:52 2016 -0400
+++ b/liboctave/util/url-transfer.cc	Mon Jun 13 09:18:03 2016 -0700
@@ -133,7 +133,7 @@
     string_vector file_list;
 
     std::string realdir
-      = (base.length () == 0
+      = (base.empty ()
          ? directory : base + octave::sys::file_ops::dir_sep_str () + directory);
 
     mkdir (directory);