[Development] Feature Freeze Exception: QStringView

Alexander Volkov a.volkov at rusbitech.ru
Wed Feb 1 10:53:45 CET 2017


31.01.2017 21:52, Thiago Macieira пишет:
> Good point, that's a point in favour of having Q{String,ByteArray}View.
>
> We need to think how that will work with having classes for exclusive
> ownership (not implicitly shared). That's the counterpart of the Views: they
> don't own, but they only have read-only access. I want to provide a solution
> for the mutating operations too.

It would be nice to have not implicitly shared string class for 
QTextStream::readLineInto().
Currently it reads into QString as in a buffer and if you need to copy 
the buffer, then you
have to manually make a deep copy of it:
     QTextStream ts(...);
     QString line;
     line.reserve(1024);
     QStringList found;
     while (ts.readLineInto(&line)) {
         ...
         found.append(QString(line.constData(), line.size())); // deep copy
     }
Otherwise the buffer will be detached and copied on the next calling of 
readLineInto() and will lose its capacity.



More information about the Development mailing list