This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] Fix second half of libstdc++/6745

Jonathan Lennox wrote:

I'm pretty sure it can't happen with any of the standard streambuf classes
defined by the C++ standard, but it can easily happen for user-defined
streambuf classes.

As an example, consider test_buffer_1 from
class test_buffer_1 : public std::streambuf {
test_buffer_1(const std::string& s) : str(s), it(str.begin()) { }
virtual int underflow() { return (it != str.end() ? *it : EOF); }
virtual int uflow() { return (it != str.end() ? *it++ : EOF); }

const std::string str;
std::string::const_iterator it;

__copy_streambufs will loop once without your patch, but s.length() times
with it, if stdin is a tty.

An actual practical example is something like Matt Austern's syncstream,
which is attached to PR 8071.

I want to study this in more detail but basically I believe you are right: we have a performance
issue in such cases. Could you possibly work out a patch along the lines which you suggested?
Not adding new public members to basic_filebuf, however...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]