[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51871] loading '-ascii' format files is slow
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #51871] loading '-ascii' format files is slow |
Date: |
Fri, 8 Sep 2017 18:43:23 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #31, bug #51871 (project octave):
There's no real reason is.get () would start returning a space (' ') on an EOF
or error case. Thus, the while loop will terminate eventually.
Also, I'm pretty sure you don't want to check eof. If the large value is the
very last value in the file then
is >> val;
will set both the fail bit and the eof bit. Then this test will say that a
true error occurred, rather than just a large value being encountered.
+ if (!is.bad () && !is.eof () && val == std::numeric_limits<T>::max ())
I went with the original coding strategy, rather than use is.fail(), because
as you'll notice in your updated patch is.readstate is called in both the if
and else branches. If it is common to both branches one might as well just
pull it up and out.
- std::ios::iostate status = is.rdstate ();
- if (status & std::ios::failbit)
+ if (is.fail ())
{
// Convert MAX_VAL returned by C++ streams for very large numbers to
Inf
- if (val == std::numeric_limits<T>::max ())
+ if (!is.bad () && !is.eof () && val == std::numeric_limits<T>::max ())
{
if (neg)
val = -std::numeric_limits<T>::infinity ();
else
val = std::numeric_limits<T>::infinity ();
- is.clear (status & ~std::ios::failbit);
+ is.clear (is.rdstate () & ~std::ios::failbit);
}
else
{
// True error. Reset stream to original position and pass status
on.
+ std::ios::iostate status = is.rdstate ();
is.clear ();
is.seekg (pos);
is.setstate (status);
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51871>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/