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

improve/optimize QStringList::join implementation

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.5.0
    • None
    • All

    Description

      I noticed that QStringList::join() always allocates a new string except for trivial case when the list is empty.

      There is however another very frequent special case which I think deserves special care and optimization - the case when the list contains only one string. In that case we can return this string and avoid allocation altogether, only increase the string refcount, which is much faster than allocation.

      And a side note: I also noticed that there are two overloads of QtPrivate::QStringList_join(). I understand the need for the two overloads but I do not know why each of them has completely different implementation, one using loop with index and the other one using iterators. I believe this should be unified, choose one of them, whichever is faster.

      Attachments

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

        Activity

          People

            ahmad.samir Ahmad Samir
            vladimir.kraus Vladimir Kraus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes