From d8c996120c0443d60f33bc156f5fc9a598911bf5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Dec 2015 20:30:42 +0100 Subject: [PATCH] QFileDialogPrivate::restoreWidgetState(): use range-erase instead of while pop_front() Depending on the number of popped arguments, repeated pop_front()s could turn quadratic even with QList. Change-Id: I1f29af4a61f0f8e13253807d2f208c7911e71378 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/widgets/dialogs/qfiledialog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 1bf5691837..07d1ab0add 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2761,8 +2761,10 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo } qFileDialogUi->sidebar->setUrls(sidebarUrls); - while (history.count() > 5) - history.pop_front(); + + static const int MaxHistorySize = 5; + if (history.size() > MaxHistorySize) + history.erase(history.begin(), history.end() - MaxHistorySize); q->setHistory(history); QHeaderView *headerView = qFileDialogUi->treeView->header();