QInputDialog: use a switch instead of a string pointer table
Effects on Linux AMD64 GCC 4.9-trunk -O2 stripped release: text: -72B data: -64B relocs: -4 Change-Id: Ie312e12ba42f58fa5dd61da1e64b9c22bf4738b2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
b52b5fa082
commit
c4a2d6ca1e
@ -60,25 +60,40 @@
|
|||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
enum CandidateSignal {
|
||||||
|
TextValueSelectedSignal,
|
||||||
|
IntValueSelectedSignal,
|
||||||
|
DoubleValueSelectedSignal,
|
||||||
|
AcceptedSignal,
|
||||||
|
|
||||||
|
NumCandidateSignals
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *candidateSignal(int which)
|
||||||
|
{
|
||||||
|
switch (CandidateSignal(which)) {
|
||||||
|
case TextValueSelectedSignal: return SIGNAL(textValueSelected(QString));
|
||||||
|
case IntValueSelectedSignal: return SIGNAL(intValueSelected(int));
|
||||||
|
case DoubleValueSelectedSignal: return SIGNAL(doubleValueSelected(double));
|
||||||
|
case AcceptedSignal: return SIGNAL(accepted());
|
||||||
|
|
||||||
|
case NumCandidateSignals: ; // fall through
|
||||||
|
};
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *signalForMember(const char *member)
|
static const char *signalForMember(const char *member)
|
||||||
{
|
{
|
||||||
static const int NumCandidates = 4;
|
|
||||||
static const char * const candidateSignals[NumCandidates] = {
|
|
||||||
SIGNAL(textValueSelected(QString)),
|
|
||||||
SIGNAL(intValueSelected(int)),
|
|
||||||
SIGNAL(doubleValueSelected(double)),
|
|
||||||
SIGNAL(accepted())
|
|
||||||
};
|
|
||||||
|
|
||||||
QByteArray normalizedMember(QMetaObject::normalizedSignature(member));
|
QByteArray normalizedMember(QMetaObject::normalizedSignature(member));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < NumCandidates - 1) { // sic
|
while (i < NumCandidateSignals - 1) { // sic
|
||||||
if (QMetaObject::checkConnectArgs(candidateSignals[i], normalizedMember))
|
if (QMetaObject::checkConnectArgs(candidateSignal(i), normalizedMember))
|
||||||
break;
|
break;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return candidateSignals[i];
|
return candidateSignal(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user