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
|
QGradientStops QGradient::stops() const
|
||||||
{
|
{
|
||||||
if (m_stops.isEmpty()) {
|
if (m_stops.isEmpty()) {
|
||||||
QGradientStops tmp;
|
static constexpr QGradientStop blackAndWhite[] = {
|
||||||
tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white);
|
{0, QColorConstants::Black}, {1, QColorConstants::White},
|
||||||
return tmp;
|
};
|
||||||
|
return QGradientStops::fromReadOnlyData(blackAndWhite);
|
||||||
}
|
}
|
||||||
return m_stops;
|
return m_stops;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user