Skip to content

Commit b0c5479

Browse files
nephrosnephros
authored andcommitted
Hotcache: Static initializer lists
1 parent 6884b81 commit b0c5479

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/bin/patchmanager-daemon/patchmanagerobject.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,20 +3027,8 @@ PatchManagerFilter::PatchManagerFilter(QObject *parent, int maxCost )
30273027
{
30283028
}
30293029

3030-
void PatchManagerFilter::setup()
3031-
{
3032-
static const char *etcList[] = {
3033-
"/etc/passwd",
3034-
"/etc/group",
3035-
"/etc/shadow",
3036-
"/etc/localtime",
3037-
"/etc/ld.so.preload",
3038-
"/etc/ld.so.cache",
3039-
"/usr/share/locale/locale.alias"
3040-
};
3041-
3042-
/* only use relatively stable sonames here. No symlinks! */
3043-
static const char *libList[] = {
3030+
/* only use relatively stable sonames here. No symlinks! */
3031+
const PatchManagerFilter::libList = QStringList({
30443032
"/usr/lib64/libtls-padding.so",
30453033
"/usr/lib64/libpreloadpatchmanager.so",
30463034
"/lib64/libc.so.6",
@@ -3053,19 +3041,30 @@ void PatchManagerFilter::setup()
30533041
"/usr/lib64/libmount.so.1",
30543042
"/usr/lib64/libblkid.so.1",
30553043
"/usr/lib64/libgpg-error.so.0"
3056-
};
3044+
});
3045+
const PatchManagerFilter::etcList = QStringList({
3046+
"/etc/passwd",
3047+
"/etc/group",
3048+
"/etc/shadow",
3049+
"/etc/localtime",
3050+
"/etc/ld.so.preload",
3051+
"/etc/ld.so.cache",
3052+
"/usr/share/locale/locale.alias"
3053+
});
30573054

3055+
void PatchManagerFilter::setup()
3056+
{
30583057
// set up cache
30593058
setMaxCost(HOTCACHE_COST_MAX);
30603059

30613060
// use a cost of 1 here so they have less chance to be evicted
3062-
foreach( const char* entry, etcList) {
3061+
for(const QString &entry : etcList) {
30633062
if (QFileInfo::exists(entry))
3064-
insert(QString(entry), new QObject(), HOTCACHE_COST_STRONG);
3063+
insert(entry, new QObject(), HOTCACHE_COST_STRONG);
30653064
}
30663065
}
30673066
// they may be wrong, so use a higher cost than default
3068-
foreach( const char* entry, libList) {
3067+
for( const QString &entry : libList) {
30693068
QString libentry(entry);
30703069
if (Q_PROCESSOR_WORDSIZE == 4) { // 32 bit
30713070
libentry.replace("lib64", "lib");

src/bin/patchmanager-daemon/patchmanagerobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class PatchManagerFilter : public QObject, public QCache<QString, QObject>
113113
bool m_active;
114114
unsigned int m_hits = 0;
115115
unsigned int m_misses = 0;
116+
117+
static const QStringList etcList;
118+
static const QStringList libList;
116119
};
117120

118121
class PatchManagerObject : public QObject, public QDBusContext

0 commit comments

Comments
 (0)