QDBusAdaptorConnector: place a static int into BSS instead of DATA

The cachedRelaySlotMethodIndex started out as -1, assuming no slot
could have that index.

But 0 is just as good a marker, because we know that method index 0
will be one of QObject's (destroyed() or deleteLater()).

So start out with a zero initial value, which means the variable can
be placed in the BSS segment now and doesn't need to be stored in
DATA.

Pick-to: 6.3 6.2
Change-Id: I40b96d54f11e60348f465cafa15af98d41038c95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2022-02-04 14:47:20 +01:00
parent 7277ffee52
commit c3c2a0f754
1 changed files with 3 additions and 3 deletions

View File

@ -58,13 +58,13 @@
QT_BEGIN_NAMESPACE
static int cachedRelaySlotMethodIndex = -1;
static int cachedRelaySlotMethodIndex = 0;
int QDBusAdaptorConnector::relaySlotMethodIndex()
{
if (cachedRelaySlotMethodIndex == -1) {
if (cachedRelaySlotMethodIndex == 0) {
cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()");
Q_ASSERT(cachedRelaySlotMethodIndex != -1);
Q_ASSERT(cachedRelaySlotMethodIndex != 0); // 0 should be deleteLater() or destroyed()
}
return cachedRelaySlotMethodIndex;
}