Details
-
Suggestion
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
4.8.x, 5.4.2
-
None
Description
It's known that "because QTextStream is buffered, this function may have to seek the device to reconstruct a valid device position. This operation can be expensive, so you may want to avoid calling this function in a tight loop."
I had a task to get offsets of all lines in a huge file. (These offsets are later shuffled and file is rewritten according to this shuffled order after that. This approach allowed to implement analogue of unix' shuf command for files bigger than available RAM.). And to achieve acceptable performance I have been forced to fork QTextStream and implement own pos() method that able to return current offset without causing seek() based on buffer offset and current pos in buffer. That required few more private int members and few lines of code.
My question is: Is there a big reason behind current QTextStream::pos() implementation? Isn't it really feasible to implement it without causing seek? May be it's worth to do, bcs it costs less efforts than forking whole QTextStream every time.