[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/icons
From: David Faure <faure () kde ! org>
Date: 2010-08-16 16:31:41
Message-ID: 20100816163141.128B3AC854 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1164379 by dfaure:
Optimizations:
- Remove duplicates in the list of paths, before checking every path for icon themes
- Add missing slash, so that we don't look for /usr/share/pixmapsoxygen (doh)
- Factorize the code that looks for index.desktop or index.theme so that we call \
access+stat only once.
Results of strace -e trace=open,access,stat ./kiconloader_unittest >& log:
Before: 82598 * access, 22518 * stat, 1082 * open
After: 73798 * access, 16694 * stat, 1082 * open
CCMAIL: kde-optimize@kde.org
CCBUG: 240009
M +4 -3 kiconcache.cpp
M +17 -16 kicontheme.cpp
--- trunk/KDE/kdelibs/kdeui/icons/kiconcache.cpp #1164378:1164379
@@ -190,16 +190,17 @@
{
// Find all possible icontheme dirs
// This has been taken from kicontheme.cpp
- const QStringList icondirs = KGlobal::dirs()->resourceDirs("icon")
+ QStringList icondirs = KGlobal::dirs()->resourceDirs("icon")
<< KGlobal::dirs()->resourceDirs("xdgdata-icon")
- << "/usr/share/pixmaps"
+ << "/usr/share/pixmaps/"
// These are not in the icon spec, but e.g. GNOME puts some icons there \
anyway. << KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
+ icondirs.removeDuplicates();
// Check which of theme actually contain existing dir of one of the
// given themes
QSet<QString> dirs;
- for (QStringList::ConstIterator it = icondirs.begin(); it != icondirs.end(); \
++it) { + for (QStringList::ConstIterator it = icondirs.constBegin(); it != \
icondirs.constEnd(); ++it) { QStringList::ConstIterator themeIt;
for (themeIt = themeNames.begin(); themeIt != themeNames.end(); ++themeIt) {
QString dirName = *it + *themeIt + '/';
--- trunk/KDE/kdelibs/kdeui/icons/kicontheme.cpp #1164378:1164379
@@ -133,7 +133,6 @@
QStringList icnlibs;
QStringList::ConstIterator it, itDir;
QStringList themeDirs;
- QString cDir;
QSet<QString> addedDirs; // Used for avoiding duplicates.
// Applications can have local additions to the global "locolor" and
@@ -144,7 +143,7 @@
( name == defaultThemeName() || name== "hicolor" || name == "locolor" ) ) {
icnlibs = KGlobal::dirs()->resourceDirs("data");
for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
- cDir = *it + appName + "/icons/" + name;
+ const QString cDir = *it + appName + "/icons/" + name;
if (QFile::exists( cDir )) {
themeDirs += cDir + '/';
}
@@ -154,33 +153,35 @@
icnlibs = KGlobal::dirs()->resourceDirs("icon")
<< KGlobal::dirs()->resourceDirs("xdgdata-icon")
- << "/usr/share/pixmaps"
+ << "/usr/share/pixmaps/"
// These are not in the icon spec, but e.g. GNOME puts some icons there \
anyway. << KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
+ icnlibs.removeDuplicates();
+
+ QString fileName, mainSection;
for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
- cDir = *it + name + '/';
+ const QString cDir = *it + name + '/';
if (KStandardDirs::exists(cDir)) {
themeDirs += cDir;
- if (d->mDir.isEmpty() &&
- (KStandardDirs::exists( cDir + "index.desktop") || \
KStandardDirs::exists( cDir + "index.theme"))) { + if (d->mDir.isEmpty()) \
{ + if (KStandardDirs::exists(cDir + "index.desktop")) {
d->mDir = cDir;
+ fileName = d->mDir + "index.desktop";
+ mainSection = "KDE Icon Theme";
+ } else if (KStandardDirs::exists(cDir + "index.theme")) {
+ d->mDir = cDir;
+ fileName = d->mDir + "index.theme";
+ mainSection = "Icon Theme";
}
}
}
+ }
if (d->mDir.isEmpty()) {
- kDebug(264) << "Icon theme " << name << " not found.\n";
+ kDebug(264) << "Icon theme" << name << "not found.";
return;
}
- QString fileName, mainSection;
- if (QFile::exists(d->mDir + "index.desktop")) {
- fileName = d->mDir + "index.desktop";
- mainSection="KDE Icon Theme";
- } else {
- fileName = d->mDir + "index.theme";
- mainSection="Icon Theme";
- }
// Use KSharedConfig to avoid parsing the file many times, from each kinstance.
// Need to keep a ref to it to make this useful
d->sharedConfig = KSharedConfig::openConfig(fileName);
@@ -207,7 +208,7 @@
KConfigGroup cg(d->sharedConfig, *it);
for (itDir=themeDirs.constBegin(); itDir!=themeDirs.constEnd(); ++itDir) {
const QString currentDir(*itDir + *it + '/');
- if (KStandardDirs::exists(currentDir) && \
!addedDirs.contains(currentDir)) { + if (!addedDirs.contains(currentDir) \
&& KStandardDirs::exists(currentDir)) { addedDirs.insert(currentDir);
KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg);
if (!dir->isValid()) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic