Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 546f8e9

Browse files
glebmxzyfer
authored andcommitted
Selector unification: use == for comparison
Extracted from #2315
1 parent 514c9c7 commit 546f8e9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/ast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ namespace Sass {
509509
{
510510
const size_t rsize = rhs->length();
511511
for (size_t i = 0; i < rsize; ++i)
512-
{ if (to_string() == rhs->at(i)->to_string()) return rhs; }
512+
{ if (*this == *rhs->at(i)) return rhs; }
513513
const int lhs_order = this->unification_order();
514514
size_t i = rsize;
515515
while (i > 0 && lhs_order < rhs->at(i - 1)->unification_order()) --i;

src/ast.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,8 @@ namespace Sass {
22042204
// dispatch to correct handlers
22052205
virtual bool operator<(const Selector& rhs) const = 0;
22062206
virtual bool operator==(const Selector& rhs) const = 0;
2207+
bool operator>(const Selector& rhs) const { return rhs < *this; };
2208+
bool operator!=(const Selector& rhs) const { return !(rhs == *this); };
22072209
ATTACH_VIRTUAL_AST_OPERATIONS(Selector);
22082210
};
22092211
inline Selector::~Selector() { }
@@ -2290,6 +2292,7 @@ namespace Sass {
22902292
{
22912293
if (hash_ == 0) {
22922294
hash_combine(hash_, std::hash<int>()(SELECTOR));
2295+
hash_combine(hash_, std::hash<int>()(simple_type()));
22932296
hash_combine(hash_, std::hash<std::string>()(ns()));
22942297
hash_combine(hash_, std::hash<std::string>()(name()));
22952298
}

0 commit comments

Comments
 (0)