Merge lp:~aacid/ubuntu-ui-toolkit/iconSearchingStringOptimizations into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Bernabei
Approved revision: 1901
Merged at revision: 1906
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/iconSearchingStringOptimizations
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~aacid/ubuntu-ui-toolkit/improveIconSearching
Diff against target: 82 lines (+11/-11)
2 files modified
src/Ubuntu/Components/plugin/unitythemeiconprovider.cpp (+10/-10)
src/Ubuntu/Components/plugin/unitythemeiconprovider.h (+1/-1)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/iconSearchingStringOptimizations
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Andrea Bernabei (community) Approve
Review via email: mp+289208@code.launchpad.net

Commit message

Some string optimizations in the icon searching code

To post a comment you must log in.
Revision history for this message
Andrea Bernabei (faenil) wrote :

ship it! :D

Revision history for this message
Andrea Bernabei (faenil) wrote :

lgtm, approved! thanks!

Revision history for this message
Andrea Bernabei (faenil) :
review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/unitythemeiconprovider.cpp'
2--- src/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2016-03-16 14:28:11 +0000
3+++ src/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2016-03-16 14:28:12 +0000
4@@ -107,7 +107,7 @@
5 }
6
7 Q_FOREACH(const QString &name, settings.value("Icon Theme/Inherits").toStringList()) {
8- if (name != "hicolor") {
9+ if (name != QLatin1String("hicolor")) {
10 parents.append(IconTheme::get(name));
11 }
12 }
13@@ -120,11 +120,11 @@
14
15 SizeType sizeTypeFromString(const QString &string)
16 {
17- if (string == "Fixed")
18+ if (string == QLatin1String("Fixed"))
19 return Fixed;
20- if (string == "Scalable")
21+ if (string == QLatin1String("Scalable"))
22 return Scalable;
23- if (string == "Threshold")
24+ if (string == QLatin1String("Threshold"))
25 return Threshold;
26 qWarning() << "IconTheme: unknown size type '" << string << "'. Assuming 'Fixed'.";
27 return Fixed;
28@@ -137,14 +137,14 @@
29 const bool anyZero = size.width() <= 0 || size.height() <= 0;
30 const Qt::AspectRatioMode scaleMode = anyZero ? Qt::KeepAspectRatioByExpanding : Qt::KeepAspectRatio;
31
32- if (filename.endsWith(".png")) {
33+ if (filename.endsWith(QLatin1String(".png"))) {
34 pixmap = QPixmap(filename);
35 if (!pixmap.isNull() && !size.isNull() && (pixmap.width() != size.width() || pixmap.height() != size.height())) {
36 const QSize newSize = pixmap.size().scaled(size.width(), size.height(), scaleMode);
37 pixmap = pixmap.scaled(newSize);
38 }
39 }
40- else if (filename.endsWith(".svg")) {
41+ else if (filename.endsWith(QLatin1String(".svg"))) {
42 QSvgRenderer renderer(filename);
43 pixmap = QPixmap(renderer.defaultSize().scaled(size.width(), size.height(), scaleMode));
44 pixmap.fill(Qt::transparent);
45@@ -158,8 +158,8 @@
46
47 QString lookupIconFile(const QString &dir, const QString &name)
48 {
49- QString png = QString("%1/%2.png").arg(dir).arg(name);
50- QString svg = QString("%1/%2.svg").arg(dir).arg(name);
51+ QString png = QStringLiteral("%1/%2.png").arg(dir, name);
52+ QString svg = QStringLiteral("%1/%2.svg").arg(dir, name);
53
54 Q_FOREACH(const QString &baseDir, baseDirs) {
55 QString filename = baseDir + "/" + png;
56@@ -268,11 +268,11 @@
57 // The hicolor theme will be searched last as per
58 // https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
59 QSet<QString> alreadySearchedThemes;
60- const QStringList names = id.split(",", QString::SkipEmptyParts);
61+ const QStringList names = id.split(QLatin1Char(','), QString::SkipEmptyParts);
62 QPixmap pixmap = theme->findBestIcon(names, requestedSize, &alreadySearchedThemes);
63
64 if (pixmap.isNull()) {
65- IconTheme::IconThemePointer theme = IconTheme::get("hicolor");
66+ IconTheme::IconThemePointer theme = IconTheme::get(QStringLiteral("hicolor"));
67 return theme->findBestIcon(names, requestedSize, nullptr);
68 }
69
70
71=== modified file 'src/Ubuntu/Components/plugin/unitythemeiconprovider.h'
72--- src/Ubuntu/Components/plugin/unitythemeiconprovider.h 2015-02-18 12:11:52 +0000
73+++ src/Ubuntu/Components/plugin/unitythemeiconprovider.h 2016-03-16 14:28:12 +0000
74@@ -24,7 +24,7 @@
75 class UnityThemeIconProvider: public QQuickImageProvider
76 {
77 public:
78- UnityThemeIconProvider(const QString &themeName = "suru");
79+ UnityThemeIconProvider(const QString &themeName = QStringLiteral("suru"));
80 QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize);
81
82 private:

Subscribers

People subscribed via source and target branches