From 546f8e979dd93586d76324ce53731d4291570f00 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 18 Nov 2018 14:36:57 +0000 Subject: [PATCH] Selector unification: use == for comparison Extracted from #2315 --- src/ast.cpp | 2 +- src/ast.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ast.cpp b/src/ast.cpp index f8da206e1..6afb3774b 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -509,7 +509,7 @@ namespace Sass { { const size_t rsize = rhs->length(); for (size_t i = 0; i < rsize; ++i) - { if (to_string() == rhs->at(i)->to_string()) return rhs; } + { if (*this == *rhs->at(i)) return rhs; } const int lhs_order = this->unification_order(); size_t i = rsize; while (i > 0 && lhs_order < rhs->at(i - 1)->unification_order()) --i; diff --git a/src/ast.hpp b/src/ast.hpp index b84990838..b970a5ae9 100644 --- a/src/ast.hpp +++ b/src/ast.hpp @@ -2204,6 +2204,8 @@ namespace Sass { // dispatch to correct handlers virtual bool operator<(const Selector& rhs) const = 0; virtual bool operator==(const Selector& rhs) const = 0; + bool operator>(const Selector& rhs) const { return rhs < *this; }; + bool operator!=(const Selector& rhs) const { return !(rhs == *this); }; ATTACH_VIRTUAL_AST_OPERATIONS(Selector); }; inline Selector::~Selector() { } @@ -2290,6 +2292,7 @@ namespace Sass { { if (hash_ == 0) { hash_combine(hash_, std::hash()(SELECTOR)); + hash_combine(hash_, std::hash()(simple_type())); hash_combine(hash_, std::hash()(ns())); hash_combine(hash_, std::hash()(name())); }