Mercurial > octave
changeset 21497:2d71bb0011a0
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.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Fri, 18 Mar 2016 23:08:18 -0700 |
parents | 5d69326e8cc5 |
children | 9cb37fede0b6 |
files | libinterp/corefcn/textscan.cc libinterp/corefcn/textscan.h |
diffstat | 2 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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<char> (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'
--- 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!