Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-46896

QTextStream::pos() could not couse seek()

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 4.8.x, 5.4.2
    • Core: I/O
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            truf Alexander Trufanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes