summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat/removed_api.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2022-03-12 16:25:33 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-23 14:46:33 +0100
commit4cf299eb5bbdbac8484c2ee8c5afbd260dccc6d5 (patch)
tree57399212a42525523fa3cf48f3f48d5a3e41ddf9 /src/corelib/compat/removed_api.cpp
parenta9cef86b8fda35bb5551b70385fee8adeea25784 (diff)
QSettings: port API from QString to QAnyStringView keys
With the public interface ported to QAnyStringView, we can now internally optimize memory allocations _in a central place_ (e.g. by returning std::u16string or QVarLengthArray<QChar> from normalizeKey() instead of QString). But first we needed to get rid of all the unwarranted allocations in user code. Effects on Linux AMD64 stripped C++20 release builds: GCC 11.2 libstdc++ (TEXT -= 6.5%): text data bss dec hex filename 635148 10992 2824 648964 9e704 tst_qsettings-01-baseline 593691 10992 2824 607507 94513 tst_qsettings-02-qanystringview Clang 10.0.0 libc++ (TEXT -= 11.6%(!)): text data bss dec hex filename 790336 10640 2832 803808 c43e0 tst_qsettings-01-baseline 698572 10640 2832 712044 add6c tst_qsettings-02-qanystringview That's the beauty of QAnyStringView: transparently reducing temporary QString creation; and the simplest code is also the most efficient. [ChangeLog][QtCore][QSettings] Keys can now be passed as QAnyStringView (was: QString). The most efficient way to pass literal keys is now "key"_L1, the backwards-compatible way is QStringLiteral("key"). Fixes: QTBUG-101390 Change-Id: I510fb4ce17ef109dac7c9cdc5d90ede0d1a9db5f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/compat/removed_api.cpp')
-rw-r--r--src/corelib/compat/removed_api.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index 64c3e9ccff..51482d1e60 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -214,6 +214,49 @@ void QObject::setObjectName(const QString &name)
}
+#include "qsettings.h"
+
+void QSettings::beginGroup(const QString &prefix)
+{
+ return beginGroup(qToAnyStringViewIgnoringNull(prefix));
+}
+
+int QSettings::beginReadArray(const QString &prefix)
+{
+ return beginReadArray(qToAnyStringViewIgnoringNull(prefix));
+}
+
+void QSettings::beginWriteArray(const QString &prefix, int size)
+{
+ beginWriteArray(qToAnyStringViewIgnoringNull(prefix), size);
+}
+
+void QSettings::setValue(const QString &key, const QVariant &value)
+{
+ setValue(qToAnyStringViewIgnoringNull(key), value);
+}
+
+void QSettings::remove(const QString &key)
+{
+ remove(qToAnyStringViewIgnoringNull(key));
+}
+
+bool QSettings::contains(const QString &key) const
+{
+ return contains(qToAnyStringViewIgnoringNull(key));
+}
+
+QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const
+{
+ return value(qToAnyStringViewIgnoringNull(key), defaultValue);
+}
+
+QVariant QSettings::value(const QString &key) const
+{
+ return value(qToAnyStringViewIgnoringNull(key));
+}
+
+
#include "qversionnumber.h"
QT_WARNING_PUSH