1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibWeb: Add a specialized NumericStyleValue::equals()

This allows fast comparison of two NumericStyleValues.
This commit is contained in:
Andreas Kling 2021-09-21 11:30:36 +02:00
parent 3e4fffec26
commit ae7bbd93b8

View file

@ -348,6 +348,13 @@ public:
float value() const { return m_value; } float value() const { return m_value; }
String to_string() const override { return String::formatted("{}", m_value); } String to_string() const override { return String::formatted("{}", m_value); }
virtual bool equals(StyleValue const& other) const override
{
if (type() != other.type())
return false;
return m_value == static_cast<NumericStyleValue const&>(other).m_value;
}
private: private:
explicit NumericStyleValue(float value) explicit NumericStyleValue(float value)
: StyleValue(Type::Numeric) : StyleValue(Type::Numeric)