Smaller cleanup in QBindingStorage
Unify code paths and avoid excessive code generation. Pick-to: 6.0.0 dev Change-Id: I4a54234dd322bba380cc45d4f9c97d97a0c93303 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
e165f416a7
commit
65759c9867
@ -1438,10 +1438,13 @@ struct QBindingStoragePrivate
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
QPropertyBindingData *getAndCreate(QUntypedPropertyData *data)
|
QPropertyBindingData *get(QUntypedPropertyData *data, bool create)
|
||||||
{
|
{
|
||||||
if (!d)
|
if (!d) {
|
||||||
|
if (!create)
|
||||||
|
return nullptr;
|
||||||
reallocate(8);
|
reallocate(8);
|
||||||
|
}
|
||||||
else if (d->used*2 >= d->size)
|
else if (d->used*2 >= d->size)
|
||||||
reallocate(d->size*2);
|
reallocate(d->size*2);
|
||||||
Q_ASSERT(d->size && (d->size & (d->size - 1)) == 0); // size is a power of two
|
Q_ASSERT(d->size && (d->size & (d->size - 1)) == 0); // size is a power of two
|
||||||
@ -1454,6 +1457,8 @@ struct QBindingStoragePrivate
|
|||||||
if (index == d->size)
|
if (index == d->size)
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
if (!create)
|
||||||
|
return nullptr;
|
||||||
++d->used;
|
++d->used;
|
||||||
new (p + index) Pair{data, QPropertyBindingData()};
|
new (p + index) Pair{data, QPropertyBindingData()};
|
||||||
return &p[index].bindingData;
|
return &p[index].bindingData;
|
||||||
@ -1499,14 +1504,12 @@ void QBindingStorage::maybeUpdateBindingAndRegister_helper(const QUntypedPropert
|
|||||||
{
|
{
|
||||||
Q_ASSERT(bindingStatus);
|
Q_ASSERT(bindingStatus);
|
||||||
QUntypedPropertyData *dd = const_cast<QUntypedPropertyData *>(data);
|
QUntypedPropertyData *dd = const_cast<QUntypedPropertyData *>(data);
|
||||||
auto storage = bindingStatus->currentlyEvaluatingBinding ?
|
auto storage = QBindingStoragePrivate(d).get(dd, /*create=*/ bindingStatus->currentlyEvaluatingBinding != nullptr);
|
||||||
QBindingStoragePrivate(d).getAndCreate(dd) :
|
|
||||||
(d ? QBindingStoragePrivate(d).get(dd) : nullptr);
|
|
||||||
if (!storage)
|
if (!storage)
|
||||||
return;
|
return;
|
||||||
if (auto *binding = storage->binding())
|
if (auto *binding = storage->binding())
|
||||||
binding->evaluateIfDirtyAndReturnTrueIfValueChanged(const_cast<QUntypedPropertyData *>(data));
|
binding->evaluateIfDirtyAndReturnTrueIfValueChanged(const_cast<QUntypedPropertyData *>(data), bindingStatus);
|
||||||
storage->registerWithCurrentlyEvaluatingBinding();
|
storage->registerWithCurrentlyEvaluatingBinding(bindingStatus->currentlyEvaluatingBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPropertyBindingData *QBindingStorage::bindingData_helper(const QUntypedPropertyData *data) const
|
QPropertyBindingData *QBindingStorage::bindingData_helper(const QUntypedPropertyData *data) const
|
||||||
@ -1516,10 +1519,7 @@ QPropertyBindingData *QBindingStorage::bindingData_helper(const QUntypedProperty
|
|||||||
|
|
||||||
QPropertyBindingData *QBindingStorage::bindingData_helper(QUntypedPropertyData *data, bool create)
|
QPropertyBindingData *QBindingStorage::bindingData_helper(QUntypedPropertyData *data, bool create)
|
||||||
{
|
{
|
||||||
auto storage = create ?
|
return QBindingStoragePrivate(d).get(data, create);
|
||||||
QBindingStoragePrivate(d).getAndCreate(data) :
|
|
||||||
QBindingStoragePrivate(d).get(data);
|
|
||||||
return storage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user