From a7885c9756d423042bd0670d82d78d8dffe9be54 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Feb 2016 15:24:38 +0100 Subject: QVector: preserve capacity in clear() This is what std::vector implementations usually do, because it minimizes memory fragmentation and useless allocations since no user will call clear() unless she intends to append new data afterwards. Fix calls to resize(0) that show how existing code tried to work around the issue. Adjust test. Port from QVERIFY(==) to QCOMPARE as a drive-by. [ChangeLog][QtCore][QVector] clear() now preserves capacity. To shed capacity, call squeeze() or swap with a default-constructed QVector object, see the documentation for an example. Change-Id: I9cebe611a97e027a89e821e64408a4741b31f1f6 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/text/qtextdocument_p.cpp') diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 348fa83756..93071aaf59 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1128,7 +1128,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle delete c.custom; } undoState = 0; - undoStack.resize(0); + undoStack.clear(); if (emitSignals && undoCommandsAvailable) emitUndoAvailable(false); if (emitSignals && redoCommandsAvailable) -- cgit v1.2.3