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

Quadratic behaviour in qlocale.cpp when building uiLanguages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.10.0 Beta2
    • Core: Locales (i18n)
    • None
    • f7b9c9f60 (dev), 7530a86df (dev), e18e50070 (6.10), 50b054eeb (6.10), 9b5c31fe6 (6.9)

      In QLocale::uiLanguages() (which, at ~250LOCs, is way too long, btw), there are several problematic operations on QStringList uiLanguages. The most obvious is the manual re-implementation of QStringList::removeDuplicates() as a quadratic instead of linear algorithm. This is easily solved by using the Real Thing™.

      But in the addIfEquivalent(), the {{insert()}}s are done in the middle, too, and it's not clear whether they're all done near the end, where it would just be "meh", but not actually cause a complexity problem. In the worst case, though, the list is built back to front, which would make the construction have quadratic complexity, too (unless prepend optimization kicks in for in-the-middle-but-near-the-front insertions, too; tbc).

      Ideally, the list would be build with only appends, iow: insertions are done in order of precedence. I haven't done enough analysis to determine whether that's feasible.

        For Gerrit Dashboard: QTBUG-138851
        # Subject Branch Project Status CR V

            Eddy Edward Welbourne
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: