This repository was archived by the owner on Oct 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2000,6 +2000,21 @@ namespace Sass {
20002000 return false ;
20012001 }
20022002
2003+ bool Number::eq (const Expression& rhs) const
2004+ {
2005+ if (const Number* r = dynamic_cast <const Number*>(&rhs)) {
2006+ size_t lhs_units = numerator_units_.size () + denominator_units_.size ();
2007+ size_t rhs_units = r->numerator_units_ .size () + r->denominator_units_ .size ();
2008+ if (!lhs_units && !rhs_units) {
2009+ return std::fabs (value () - r->value ()) < NUMBER_EPSILON;
2010+ }
2011+ return (numerator_units_ == r->numerator_units_ ) &&
2012+ (denominator_units_ == r->denominator_units_ ) &&
2013+ std::fabs (value () - r->value ()) < NUMBER_EPSILON;
2014+ }
2015+ return false ;
2016+ }
2017+
20032018 bool Number::operator == (const Expression& rhs) const
20042019 {
20052020 if (const Number* r = dynamic_cast <const Number*>(&rhs)) {
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ namespace Sass {
152152 static std::string type_name () { return " " ; }
153153 virtual bool is_false () { return false ; }
154154 virtual bool operator == (const Expression& rhs) const { return false ; }
155+ virtual bool eq (const Expression& rhs) const { return *this == rhs; };
155156 virtual void set_delayed (bool delayed) { is_delayed (delayed); }
156157 virtual bool has_interpolant () const { return is_interpolant (); }
157158 virtual bool is_left_interpolant () const { return is_interpolant (); }
@@ -289,7 +290,7 @@ namespace Sass {
289290 };
290291 struct CompareExpression {
291292 bool operator ()(const Expression* lhs, const Expression* rhs) const {
292- return lhs && rhs && * lhs == *rhs;
293+ return lhs && rhs && lhs-> eq ( *rhs) ;
293294 }
294295 };
295296 typedef std::unordered_map<
@@ -1371,6 +1372,7 @@ namespace Sass {
13711372
13721373 virtual bool operator < (const Number& rhs) const ;
13731374 virtual bool operator == (const Expression& rhs) const ;
1375+ virtual bool eq (const Expression& rhs) const ;
13741376
13751377 ATTACH_OPERATIONS ()
13761378 };
You can’t perform that action at this time.
0 commit comments