core: qPref replace COPY_TXT with copy_txt in qPrefPrivate

Add copy_txt function to qPrefPrivate class
Remove macro COPY_TXT from qPrefPrivate.h
Replace use of COPY_TXT with copy_txt in qPref classes

copy_txt is only once, COPY_TXT was expanded approx. 160 times, so
this commit saves space (and removes a macro).

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-07-18 20:47:59 +02:00 committed by Dirk Hohndel
parent 597aa75348
commit f1648d297b
4 changed files with 17 additions and 15 deletions

View file

@ -3,7 +3,6 @@
#define QPREFPRIVATE_H
// Header used by all qPref<class> implementations to avoid duplicating code
#include <QSettings>
#include <QVariant>
#include <QObject>
@ -18,17 +17,13 @@ public:
QSettings setting;
// Helper functions
static void copy_txt(const char **name, const QString& string);
private:
qPrefPrivate(QObject *parent = NULL);
};
//****** Macros to be used in the set functions ******
#define COPY_TXT(name, string) \
{ \
free((void *)prefs.name); \
prefs.name = copy_qstring(string); \
}
//****** Macros to be used in the disk functions, which are special ******
#define LOADSYNC_BOOL(name, field) \
{ \
@ -191,7 +186,7 @@ void qPref ## usegroup::set_ ## field (int value) \
void qPref ## usegroup::set_ ## field (const QString& value) \
{ \
if (value != prefs.field) { \
COPY_TXT(field, value); \
qPrefPrivate::instance()->copy_txt(&prefs.field, value); \
disk_ ## field(true); \
emit field ## _changed(value); \
} \