Mercurial > octave
changeset 21471:57dea7b5ca46
textscan.cc: avoid integer constants, raising compile time issues,
when octave_idx_type is long. More style fixes.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Fri, 18 Mar 2016 09:33:43 +0100 |
parents | bbf3814049e2 |
children | 1b48a5d04fb1 |
files | libinterp/corefcn/textscan.cc |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/textscan.cc Thu Mar 17 23:37:13 2016 -0700 +++ b/libinterp/corefcn/textscan.cc Fri Mar 18 09:33:43 2016 +0100 @@ -929,24 +929,21 @@ // Create our own buffered stream, for fast get/putback/tell/seek. - // First, see how far ahead it should let us look. + // First, see how far ahead it should let us look. int max_lookahead = std::max (std::max (comment_len, treat_as_empty_len), std::max (delim_len, 3)); // 3 for NaN and Inf - // Next, choose a buffer size to avoid reading too much, or too often. - octave_idx_type buf_size; + // Next, choose a buffer size to avoid reading too much, or too often. + octave_idx_type buf_size = 4096; if (buffer_size) buf_size = buffer_size; else if (ntimes > 0) { - buf_size = 80 * ntimes; - if (buf_size < ntimes) // if overflow... - buf_size = ntimes; - buf_size = std::max (ntimes, std::min (buf_size, 4096)); + // Avoid overflow of 80*ntimes... + buf_size = std::min (buf_size, std::max (ntimes, 80 * ntimes)); + buf_size = std::max (buf_size, ntimes); } - else - buf_size = 4096; - // Finally, create the stream. + // Finally, create the stream. dstr is (*isp, whitespace + delims, max_lookahead, buf_size); // Grow retval dynamically. "size" is half the initial size