Optimization in KDE Base
KConfigXT performance fix: no need to reparse when nothing to save
Somehow I forgot to commit this after review 103166 was approved
(for KDE/4.7, in 2011 !!!). Not sure why it was "marked as submitted",
I couldn't find this commit in any branches.
Closing a kmail composer window takes a very long time, because it's calling
writeConfig() on 7 kconfigskeleton objects (see KMKernel::slotSyncConfig), and
each of them calls KConfig::sync() [that's ok, it doesn't do anything if there's
no change to save, i.e. no dirty entry] followed by readConfig(), which calls
KConfig::reparseConfiguration(). That's a lot of config file parsing, for a
case where *nothing has changed*.
Looking into the history of the kconfigskeleton code didn't help finding out
why writeConfig calls readConfig, this was added by Waldo in the initial
code in 2003.
A real sync() with dirty entries triggers a reparsing (to merge changes on-disk
with changes in memory), so it makes sense to propagate the changes from KConfig
to the KConfigSkeleton member variables after a sync. But not when sync does
nothing at all.