# HG changeset patch # User Mike Miller # Date 1458367698 25200 # Node ID 2d71bb0011a08814b3ac412db4bb148c3bdd0be3 # Parent 5d69326e8cc5dc62d79dd6661334d9a009f1570b textscan: Use empty () rather than 'length () == 0' on strings * textscan.cc (textscan_format_list::textscan_format_list, textscan_format_list::read_first_row, textscan::scan_one, textscan::parse_options): Use empty () instead of checking length () for clarity. * textscan.h (textscan::is_delim, textscan::whitespace_delim): Likewise. diff -r 5d69326e8cc5 -r 2d71bb0011a0 libinterp/corefcn/textscan.cc --- a/libinterp/corefcn/textscan.cc Fri Mar 18 22:37:52 2016 -0700 +++ b/libinterp/corefcn/textscan.cc Fri Mar 18 23:08:18 2016 -0700 @@ -629,7 +629,7 @@ bool have_more = true; - if (s.length () == 0) + if (s.empty ()) { buf = new std::ostringstream ("%f"); bitwidth = 64; @@ -1128,7 +1128,7 @@ is.getline (first_line, static_cast (ts.eol2)); - if (first_line.length () > 0 + if (! first_line.empty () && first_line[first_line.length () - 1] == ts.eol1) first_line.resize (first_line.length () - 1); @@ -2163,7 +2163,7 @@ Cell (octave_value (vv))); // FIXME -- why does failbit get set at EOF, instead of eofbit? - if (vv.length () != 0) + if (! vv.empty ()) is.clear (is.rdstate () & ~std::ios_base::failbit); } @@ -2497,7 +2497,7 @@ // For Matlab compatibility, add 0x20 to whitespace, unless // whitespace is explicitly ignored. - if (! (whitespace.length () == 0 && fmt_list.has_string)) + if (! (whitespace.empty () && fmt_list.has_string)) whitespace_table[' '] = '1'; // Create look-up table of delimiters, based on 'delimiter' diff -r 5d69326e8cc5 -r 2d71bb0011a0 libinterp/corefcn/textscan.h --- a/libinterp/corefcn/textscan.h Fri Mar 18 22:37:52 2016 -0700 +++ b/libinterp/corefcn/textscan.h Fri Mar 18 23:08:18 2016 -0700 @@ -174,15 +174,14 @@ bool is_delim (unsigned char ch) const { - return ((delim_table.length () == 0 - && (isspace (ch) || ch == eol1 || ch == eol2)) + return ((delim_table.empty () && (isspace (ch) || ch == eol1 || ch == eol2)) || delim_table[ch] != '\0'); } bool isspace (unsigned int ch) const { return whitespace_table[ch & 0xff]; } // True if the only delimiter is whitespace. - bool whitespace_delim (void) const { return delim_table.length () == 0; } + bool whitespace_delim (void) const { return delim_table.empty (); } // No copying!