Skip to content

Commit

Permalink
Selector unification: use == for comparison
Browse files Browse the repository at this point in the history
Extracted from sass#2315
  • Loading branch information
glebm authored and xzyfer committed Nov 20, 2018
1 parent 514c9c7 commit 546f8e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down Expand Up @@ -2290,6 +2292,7 @@ namespace Sass {
{
if (hash_ == 0) {
hash_combine(hash_, std::hash<int>()(SELECTOR));
hash_combine(hash_, std::hash<int>()(simple_type()));
hash_combine(hash_, std::hash<std::string>()(ns()));
hash_combine(hash_, std::hash<std::string>()(name()));
}
Expand Down

0 comments on commit 546f8e9

Please sign in to comment.