Change in plasma-framework[master]: Do not keep reparsing plasmarc configuration

David Edmundson (Code Review) noreply at kde.org
Thu Dec 11 00:06:30 UTC 2014


David Edmundson has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/214

Change subject: Do not keep reparsing plasmarc configuration
......................................................................

Do not keep reparsing plasmarc configuration

KConfig->reparseConfiguration is expensive. It throws away our cached
values.

The Units constructor was calling this every single time. Units is
created a _lot_; once per applet and once per FrameSVGItem.

This meant we were reloading the same config ~100 times on startup for
no reason.

Perf showed this as being ~5% of the total startup time.

-    7.47%     0.00%      plasmashell  libKF5ConfigCore.so.5.5.0
                   [.] KConfig::reparseConfiguration()

   - KConfig::reparseConfiguration()

      + 66.51% Units::settingsFileChanged(QString const&)

      + 25.95% KConfig::KConfig(QString const&,
QFlags<KConfig::OpenFlag>, QStandardPaths::StandardLocation)

      + 3.93% KDesktopFile::KDesktopFile(QString const&)

      + 3.61% Units::settingsFileChanged(QString const&)

Change-Id: Ia70b7001ba473c8063e6c999b8e4233ea5b206f5
---
M src/declarativeimports/core/units.cpp
M src/declarativeimports/core/units.h
2 files changed, 20 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/plasma-framework refs/changes/14/214/1

diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp
index ba06553..43533df 100644
--- a/src/declarativeimports/core/units.cpp
+++ b/src/declarativeimports/core/units.cpp
@@ -1,6 +1,7 @@
 /***************************************************************************
  *   Copyright 2013 Marco Martin <mart at kde.org>                            *
  *   Copyright 2014 Sebastian Kügler <sebas at kde.org>                       *
+ *   Copyright 2014 David Edmundson <davidedmunsdon at kde.org>               *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -59,8 +60,8 @@
     connect(KDirWatch::self(), &KDirWatch::dirty, this, &Units::settingsFileChanged);
     // ... but also remove/recreate cycles, like KConfig does it
     connect(KDirWatch::self(), &KDirWatch::created, this, &Units::settingsFileChanged);
-    // Trigger configuration read
-    settingsFileChanged(plasmarc);
+    // read configuration
+    updatePlasmaRCSettings();
 }
 
 Units::~Units()
@@ -70,18 +71,24 @@
 void Units::settingsFileChanged(const QString &file)
 {
     if (file.endsWith(plasmarc)) {
-
-        KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig(plasmarc), groupName);
-        cfg.config()->reparseConfiguration();
-        const int longDuration = cfg.readEntry("longDuration", defaultLongDuration);
-
-        if (longDuration != m_longDuration) {
-            m_longDuration = longDuration;
-            emit durationChanged();
-        }
+        KSharedConfigPtr cfg = KSharedConfig::openConfig(plasmarc);
+        cfg->reparseConfiguration();
+        updatePlasmaRCSettings();
     }
 }
 
+void Units::updatePlasmaRCSettings()
+{
+    KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig(plasmarc), groupName);
+    const int longDuration = cfg.readEntry("longDuration", defaultLongDuration);
+
+    if (longDuration != m_longDuration) {
+        m_longDuration = longDuration;
+        emit durationChanged();
+    }
+}
+
+
 void Units::iconLoaderSettingsChanged()
 {
     // These are not scaled, we respect the user's setting over dpi scaling
diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h
index e1d9bde..a469423 100644
--- a/src/declarativeimports/core/units.h
+++ b/src/declarativeimports/core/units.h
@@ -164,11 +164,12 @@
 
 private Q_SLOTS:
     void iconLoaderSettingsChanged();
-    void settingsFileChanged(const QString &settings);
+    void settingsFileChanged(const QString &file);
 
 private:
     void updateDevicePixelRatio();
     void updateSpacing();
+    void updatePlasmaRCSettings();
     /**
      * @return The dpi-adjusted size for a given icon size
      */

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/214
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia70b7001ba473c8063e6c999b8e4233ea5b206f5
Gerrit-PatchSet: 1
Gerrit-Project: plasma-framework
Gerrit-Branch: master
Gerrit-Owner: David Edmundson <david at davidedmundson.co.uk>
Gerrit-Reviewer: Sebastian Kügler <sebas at kde.org>


More information about the Plasma-devel mailing list