diff options
author | Albert Astals Cid <aacid@kde.org> | 2019-10-30 19:23:26 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2019-10-30 19:23:34 +0100 |
commit | ee72e7e7916d9b166403c74fd3eb8e874176106e (patch) | |
tree | c80a397ab5793414b92a2dec21ea28afa2e45f05 | |
parent | 80bf4c029e4cce085497f018193f0b7551f9e744 (diff) | |
download | kconfig-ee72e7e7916d9b166403c74fd3eb8e874176106e.tar.gz kconfig-ee72e7e7916d9b166403c74fd3eb8e874176106e.tar.bz2 |
kconfig_compiler: Move the KSharedConfig::Ptr when using them
Summary:
The generated classes of kconfig_compiler take a KSharedConfig::Ptr by
value, one possibility would be to make them const & but that is BIC so
instead what we do is just move them to the only place the config is
used so the cheaper move constructor can be used instead of the copy
constructor
Reviewers: ervin, apol
Reviewed By: ervin, apol
Subscribers: kde-frameworks-devel, ervin, apol
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D25061
-rw-r--r-- | autotests/kconfig_compiler/test8a.cpp.ref | 2 | ||||
-rw-r--r-- | autotests/kconfig_compiler/test8c.cpp.ref | 4 | ||||
-rw-r--r-- | src/kconfig_compiler/kconfig_compiler.cpp | 12 |
3 files changed, 11 insertions, 7 deletions
diff --git a/autotests/kconfig_compiler/test8a.cpp.ref b/autotests/kconfig_compiler/test8a.cpp.ref index 7c2b81ad..3cb835ee 100644 --- a/autotests/kconfig_compiler/test8a.cpp.ref +++ b/autotests/kconfig_compiler/test8a.cpp.ref @@ -4,7 +4,7 @@ #include "test8a.h" Test8a::Test8a( KSharedConfig::Ptr config, QObject *parent ) - : KConfigSkeleton( config ) + : KConfigSkeleton( std::move( config ) ) { setParent(parent); setCurrentGroup( QStringLiteral( "Group" ) ); diff --git a/autotests/kconfig_compiler/test8c.cpp.ref b/autotests/kconfig_compiler/test8c.cpp.ref index e2bd027c..d806ca79 100644 --- a/autotests/kconfig_compiler/test8c.cpp.ref +++ b/autotests/kconfig_compiler/test8c.cpp.ref @@ -41,12 +41,12 @@ void Test8c::instance(KSharedConfig::Ptr config) qDebug() << "Test8c::instance called after the first use - ignoring"; return; } - new Test8c(config); + new Test8c(std::move(config)); s_globalTest8c()->q->read(); } Test8c::Test8c( KSharedConfig::Ptr config, QObject *parent ) - : KConfigSkeleton( config ) + : KConfigSkeleton( std::move( config ) ) { setParent(parent); Q_ASSERT(!s_globalTest8c()->q); diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index c648d7d0..054dbd4d 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -2344,7 +2344,7 @@ int main(int argc, char **argv) cpp << "}" << endl << endl; if (cfgFileNameArg) { - auto instance = [&cfg, &cpp] (const QString &type, const QString &arg, bool wrap) { + auto instance = [&cfg, &cpp] (const QString &type, const QString &arg, bool isString) { cpp << "void " << cfg.className << "::instance(" << type << " " << arg << ")" << endl; cpp << "{" << endl; cpp << " if (s_global" << cfg.className << "()->q) {" << endl; @@ -2352,10 +2352,10 @@ int main(int argc, char **argv) cpp << " return;" << endl; cpp << " }" << endl; cpp << " new " << cfg.className << "("; - if (wrap) { + if (isString) { cpp << "KSharedConfig::openConfig(" << arg << ")"; } else { - cpp << arg; + cpp << "std::move(" << arg << ")"; } cpp << ");" << endl; cpp << " s_global" << cfg.className << "()->q->read();" << endl; @@ -2402,7 +2402,11 @@ int main(int argc, char **argv) cpp << " QStringLiteral( \"" << cfgFileName << "\" "; } if (cfgFileNameArg) { - cpp << " config "; + if (! cfg.forceStringFilename) { + cpp << " std::move( config ) "; + } else { + cpp << " config "; + } } if (!cfgFileName.isEmpty()) { cpp << ") "; |