QGradient: optimize empty stops
Don't allocate memory, use QList::fromReadOnlyData() over a static constexpr array instead. Change-Id: I596a3d61d5dd9603eea7f72a88d627af63ca54cd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f3e006a698
commit
b612014ae7
@ -1664,9 +1664,10 @@ void QGradient::setStops(const QGradientStops &stops)
|
||||
QGradientStops QGradient::stops() const
|
||||
{
|
||||
if (m_stops.isEmpty()) {
|
||||
QGradientStops tmp;
|
||||
tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white);
|
||||
return tmp;
|
||||
static constexpr QGradientStop blackAndWhite[] = {
|
||||
{0, QColorConstants::Black}, {1, QColorConstants::White},
|
||||
};
|
||||
return QGradientStops::fromReadOnlyData(blackAndWhite);
|
||||
}
|
||||
return m_stops;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user