cc6324665e
Instead of detaching when the string is shared, or if the the insertion would cause a reallocation, create a new string and copy characters to it as needed, then swap it with "this" string. This is more efficient than detaching which would copy the whole string before inserting, as some characters would be copied multiple times. Use detachAndGrow(), otherwise QStringBuilder unitests fail: PASS : tst_QStringBuilder1::initTestCase() FAIL! : tst_QStringBuilder1::scenario() 'prepends < max_prepends' returned FALSE. () Loc: [tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp(61)] PASS : tst_QStringBuilder1::cleanupTestCase() The issue is that now when inserting, if the string is going to reallocated, we create a new string, so the freeSpaceAtBegin() optimization doesn't work the same way. void checkItWorksWithFreeSpaceAtBegin(const String &chunk, const Separator &separator) { // GIVEN: a String with freeSpaceAtBegin() and less than chunk.size() freeSpaceAtEnd() String str; int prepends = 0; const int max_prepends = 10; while (str.data_ptr().freeSpaceAtBegin() < chunk.size() && prepends++ < max_prepends) str.prepend(chunk); QVERIFY(prepends < max_prepends); ... ... each str.prepend() would have reallocated. [ChangeLog][QtCore][QString] Calling insert() on a currently shared string is now done more efficiently. Task-number: QTBUG-106186 Change-Id: I07ce8d6bde50919fdc587433e624ace9cee05be8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> |
||
---|---|---|
.. | ||
auto | ||
baseline | ||
benchmarks | ||
global | ||
libfuzzer | ||
manual | ||
shared | ||
testserver | ||
CMakeLists.txt | ||
README |
This directory contains autotests and benchmarks based on Qt Test. In order to run the autotests reliably, you need to configure a desktop to match the test environment that these tests are written for. Linux X11: * The user must be logged in to an active desktop; you can't run the autotests without a valid DISPLAY that allows X11 connections. * The tests are run against a KDE3 or KDE4 desktop. * Window manager uses "click to focus", and not "focus follows mouse". Many tests move the mouse cursor around and expect this to not affect focus and activation. * Disable "click to activate", i.e., when a window is opened, the window manager should automatically activate it (give it input focus) and not wait for the user to click the window.