aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsfunctioninitializer.cpp
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2025-01-11 13:45:05 +0100
committerSami Shalayel <sami.shalayel@qt.io>2025-01-24 15:50:49 +0100
commit80e17e4bee2a78f5d485c73dd2af5437919be175 (patch)
treee8447e530b4185cc2b9f6ef01db043dd07486df8 /src/qmlcompiler/qqmljsfunctioninitializer.cpp
parent44beb8080c44c1956d15c1df5de984614612fd68 (diff)
dom: Make path appending O(n) instead of O(nˆ2)
Path::withPath() appends paths together. Remove the old O(n^2) algorithm and use a linear one instead. Remove the broken string optimization algorithm that tries to not re-add string data that already exists in the Path. On one side it does not work, the implementation of inQString always returns false (the 'diff' variable is always negative because of the if condition above). On the other side, we don't have a use case for this optimization. We don't have equal strings in the same path in the DOM, except for fields (but fields have no string data, see also the comment on Path::withComponent()). Therefore, add all string data inconditionally when concatenating paths, even if we might end up strings that are not required. Collect all the components by iterating backwards on the path (from current to all the (indirect) parents) to get a linear complexity instead of the quadratic one you get by using `component()` in a loop. Add tests to make sure that appending sliced paths (with m_endOffset != 0 and where the underlying path actually is longer m_length) works correctly. On the tst_qmldomconstruction:default-deeplyNested.qml benchmark, this commit enhances the runtime from 414 ms to 264 ms (average over three runs on a release build) because of the complexity change of Path::withPath from O(n^2) to O(n). Task-number: QTBUG-92889 Change-Id: I912a75d79f6e13384ae80b6d8e75cfc790d685d0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp')
0 files changed, 0 insertions, 0 deletions