From 7a99593f58113670324f7b530ec19ea061620261 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 22 Sep 2014 15:49:14 +0200 Subject: [PATCH] Task: Use a static cache for the error and warning icons Saves around 33% of testGccOutputParsers runtime. Change-Id: I5c6d0f8af8a36c153e84907e77643f4e20c8f6a1 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/task.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp index eaa3c87a54c..a6fe3466394 100644 --- a/src/plugins/projectexplorer/task.cpp +++ b/src/plugins/projectexplorer/task.cpp @@ -37,17 +37,16 @@ namespace ProjectExplorer { -static QString taskTypeIcon(Task::TaskType t) +static QIcon taskTypeIcon(Task::TaskType t) { - switch (t) { - case Task::Warning: - return QLatin1String(Core::Constants::ICON_WARNING); - case Task::Error: - return QLatin1String(Core::Constants::ICON_ERROR); - case Task::Unknown: - break; - } - return QString(); + static QIcon icons[3] = { QIcon(), + QIcon(QLatin1String(Core::Constants::ICON_ERROR)), + QIcon(QLatin1String(Core::Constants::ICON_WARNING)) }; + + if (t < 0 || t > 2) + t = Task::Unknown; + + return icons[t]; } unsigned int Task::s_nextId = 1; @@ -66,7 +65,7 @@ Task::Task(TaskType type_, const QString &description_, const Utils::FileName &iconFile) : taskId(s_nextId), type(type_), description(description_), file(file_), line(line_), movedLine(line_), category(category_), - icon(iconFile.isEmpty() ? taskTypeIcon(type_) : iconFile.toString()) + icon(iconFile.isEmpty() ? taskTypeIcon(type_) : QIcon(iconFile.toString())) { ++s_nextId; }