Bug 1270515 - Bonus fix: Factor out unnecessary Reset calls during nsStyleCoord initialization. r=dbaron

The previous patches prevent us from generating temporaries at the affected callsites,
but this could still have benefits in other places.
This commit is contained in:
Bobby Holley 2016-05-05 16:50:16 -07:00
Родитель 23b53c3cad
Коммит 21a222e332
1 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -243,6 +243,15 @@ public:
static inline void SetValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
const nsStyleCoord& aOther);
// Like the above, but do not reset before setting.
static inline void InitWithValue(nsStyleUnit& aUnit,
nsStyleUnion& aValue,
nsStyleUnit aOtherUnit,
const nsStyleUnion& aOtherValue);
static inline void InitWithValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
const nsStyleCoord& aOther);
private:
nsStyleUnit mUnit;
nsStyleUnion mValue;
@ -368,13 +377,13 @@ inline nsStyleCoord::nsStyleCoord(nscoord aValue, CoordConstructorType)
inline nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy)
: mUnit(eStyleUnit_Null)
{
SetValue(mUnit, mValue, aCopy);
InitWithValue(mUnit, mValue, aCopy);
}
inline nsStyleCoord::nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit)
: mUnit(eStyleUnit_Null)
{
SetValue(mUnit, mValue, aUnit, aValue);
InitWithValue(mUnit, mValue, aUnit, aValue);
}
inline bool nsStyleCoord::operator!=(const nsStyleCoord& aOther) const
@ -483,7 +492,15 @@ nsStyleCoord::SetValue(nsStyleUnit& aUnit,
const nsStyleUnion& aOtherValue)
{
Reset(aUnit, aValue);
InitWithValue(aUnit, aValue, aOtherUnit, aOtherValue);
}
/* static */ inline void
nsStyleCoord::InitWithValue(nsStyleUnit& aUnit,
nsStyleUnion& aValue,
nsStyleUnit aOtherUnit,
const nsStyleUnion& aOtherValue)
{
aUnit = aOtherUnit;
aValue = aOtherValue;
@ -503,6 +520,13 @@ nsStyleCoord::SetValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
SetValue(aUnit, aValue, aOther.mUnit, aOther.mValue);
}
/* static */ inline void
nsStyleCoord::InitWithValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
const nsStyleCoord& aOther)
{
InitWithValue(aUnit, aValue, aOther.mUnit, aOther.mValue);
}
// -------------------------
// nsStyleSides inlines