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

QByteArray::indexOf(char) faster than QByteArrayView(QByteArray)::indexOf(char)

    XMLWordPrintable

Details

    • b347d4870 (dev), f5021835d (dev), dfe968e97 (dev), 5ea4e2766 (dev)

    Description

      To some surprise by chance it was seen that for a given QByteArray instance the code is faster when it does not directly call indexOf(char) on it, but instead calls the indexOf(char) only on a QByteArrayView on that QByteArray instance.

      Looking at the Qt code the cause seems to be that that QByteArrayView::indexOf(char) is an inlined method, so can be optimized by the compiler. While QByteArray::indexOf(char) is not, and internally actually also just forwards the the very QByteArrayView method, so is more expensive due to the need to always invoke the method symbol.

      Perhaps could be solved by making QByteArray::indexOf(char) also inline, using the QT_CORE_INLINE_SINCE approach introduced elsewhere, I guess?

      Attachments

        1. main.cpp
          0.7 kB
          Friedrich W. H. Kossebau
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            kossebau Friedrich W. H. Kossebau
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes