From 679fcb31a69194c2d80f0aa0ff9dafeb310b132c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Mon, 17 Jun 2013 02:47:43 +0200 Subject: Speed up construction of the history page The old version was taking ages to even appear on my setup ("ages" being defined as many minutes at least). Callgrind was crashing, perhaps due to webkit's JIT, so I simply sampled the backtrace "randomly" by hand to see where the most CPU time was being spent. These two methods came up way too often, so I did the following: 1) Do not use KIconLoader within the inner loop, it's slow. It was slow when I debugged too long startup of KPhotoAlbum, it produced visible file IO, and it is trivial to speed this up. However, it was still taking time. 2) Do not request the ".historyitem" over and over again. A cached "pre-found" copy (we're still cloning it) seems to help. Together, these make it possible to load the history in <4 minutes here. It's still a completely insane amount of time, but at least it appears, ultimately. REVIEW:111053 --- src/rekonqpage/newtabpage.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 58451d17..46220514 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -458,6 +458,8 @@ void NewTabPage::historyPage(const QString & filter) int i = 0; const int maxTextSize = 103; const int truncateSize = 100; + const QString removeIconPath = QL1S("file:///") + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState); + QWebElement historyItemElement = markup(QL1S(".historyitem")); do { QModelIndex index = proxy->index(i, 0, QModelIndex()); @@ -473,7 +475,7 @@ void NewTabPage::historyPage(const QString & filter) QModelIndex son = proxy->index(j, 0, index); KUrl u = son.data(HistoryModel::UrlStringRole).toUrl(); - historyFolderElement.appendInside(markup(QL1S(".historyitem"))); + historyFolderElement.appendInside(historyItemElement.clone()); QWebElement item = historyFolderElement.lastChild(); item.findFirst(QL1S(".greytext")).setPlainText( son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm") ); @@ -494,8 +496,7 @@ void NewTabPage::historyPage(const QString & filter) linkElement.appendInside(shownUrl); QWebElement removeElement = item.findFirst(QL1S(".button img")); - removeElement.setAttribute(QL1S("src"), QL1S("file:///") + - KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + removeElement.setAttribute(QL1S("src"), removeIconPath); QWebElement removeLinkElement = item.findFirst(QL1S(".button")); -- cgit v1.2.1