Skip to content

Commit b4e24d7

Browse files
committed
Remove pointer compare functions
1 parent 7014f55 commit b4e24d7

File tree

3 files changed

+29
-103
lines changed

3 files changed

+29
-103
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ ifeq ($(UNAME),Darwin)
118118
endif
119119

120120
ifneq (MinGW,$(UNAME))
121-
ifneq (FreeBSD,$(UNAME))
122-
LDFLAGS += -ldl
123-
LDLIBS += -ldl
124-
endif
121+
ifneq (FreeBSD,$(UNAME))
122+
LDFLAGS += -ldl
123+
LDLIBS += -ldl
124+
endif
125125
endif
126126

127127
ifneq ($(BUILD),shared)

src/ast.cpp

Lines changed: 25 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,50 +1469,35 @@ namespace Sass {
14691469
return string();
14701470
}
14711471

1472-
bool Custom_Warning::operator== (const Expression* rhs) const
1472+
bool Custom_Warning::operator== (const Expression& rhs) const
14731473
{
1474-
if (const Custom_Warning* r = dynamic_cast<const Custom_Warning*>(rhs)) {
1474+
if (const Custom_Warning* r = dynamic_cast<const Custom_Warning*>(&rhs)) {
14751475
return message() == r->message();
14761476
}
14771477
return false;
14781478
}
14791479

1480-
bool Custom_Warning::operator== (const Expression& rhs) const
1481-
{
1482-
return operator==(&rhs);
1483-
}
1484-
1485-
bool Custom_Error::operator== (const Expression* rhs) const
1480+
bool Custom_Error::operator== (const Expression& rhs) const
14861481
{
1487-
if (const Custom_Error* r = dynamic_cast<const Custom_Error*>(rhs)) {
1482+
if (const Custom_Error* r = dynamic_cast<const Custom_Error*>(&rhs)) {
14881483
return message() == r->message();
14891484
}
14901485
return false;
14911486
}
14921487

1493-
bool Custom_Error::operator== (const Expression& rhs) const
1494-
{
1495-
return operator==(&rhs);
1496-
}
1497-
1498-
bool Number::operator== (const Expression* rhs) const
1488+
bool Number::operator== (const Expression& rhs) const
14991489
{
1500-
if (const Number* r = dynamic_cast<const Number*>(rhs)) {
1490+
if (const Number* r = dynamic_cast<const Number*>(&rhs)) {
15011491
return (value() == r->value()) &&
15021492
(numerator_units_ == r->numerator_units_) &&
15031493
(denominator_units_ == r->denominator_units_);
15041494
}
15051495
return false;
15061496
}
15071497

1508-
bool Number::operator== (const Expression& rhs) const
1509-
{
1510-
return operator==(&rhs);
1511-
}
1512-
1513-
bool Number::operator< (const Number* rhs) const
1498+
bool Number::operator< (const Number& rhs) const
15141499
{
1515-
Number tmp_r(*rhs);
1500+
Number tmp_r(rhs);
15161501
tmp_r.normalize(find_convertible_unit());
15171502
string l_unit(unit());
15181503
string r_unit(tmp_r.unit());
@@ -1522,44 +1507,29 @@ namespace Sass {
15221507
return value() < tmp_r.value();
15231508
}
15241509

1525-
bool Number::operator< (const Number& rhs) const
1526-
{
1527-
return operator<(&rhs);
1528-
}
1529-
1530-
bool String_Quoted::operator== (const Expression* rhs) const
1510+
bool String_Quoted::operator== (const Expression& rhs) const
15311511
{
1532-
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(rhs)) {
1512+
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(&rhs)) {
15331513
return (value() == qstr->value());
1534-
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(rhs)) {
1514+
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(&rhs)) {
15351515
return (value() == cstr->value());
15361516
}
15371517
return false;
15381518
}
15391519

1540-
bool String_Quoted::operator== (const Expression& rhs) const
1541-
{
1542-
return operator==(&rhs);
1543-
}
1544-
1545-
bool String_Constant::operator== (const Expression* rhs) const
1520+
bool String_Constant::operator== (const Expression& rhs) const
15461521
{
1547-
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(rhs)) {
1522+
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(&rhs)) {
15481523
return (value() == qstr->value());
1549-
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(rhs)) {
1524+
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(&rhs)) {
15501525
return (value() == cstr->value());
15511526
}
15521527
return false;
15531528
}
15541529

1555-
bool String_Constant::operator== (const Expression& rhs) const
1556-
{
1557-
return operator==(&rhs);
1558-
}
1559-
1560-
bool String_Schema::operator== (const Expression* rhs) const
1530+
bool String_Schema::operator== (const Expression& rhs) const
15611531
{
1562-
if (const String_Schema* r = dynamic_cast<const String_Schema*>(rhs)) {
1532+
if (const String_Schema* r = dynamic_cast<const String_Schema*>(&rhs)) {
15631533
if (length() != r->length()) return false;
15641534
for (size_t i = 0, L = length(); i < L; ++i) {
15651535
Expression* rv = (*r)[i];
@@ -1572,27 +1542,17 @@ namespace Sass {
15721542
return false;
15731543
}
15741544

1575-
bool String_Schema::operator== (const Expression& rhs) const
1576-
{
1577-
return operator==(&rhs);
1578-
}
1579-
1580-
bool Boolean::operator== (const Expression* rhs) const
1545+
bool Boolean::operator== (const Expression& rhs) const
15811546
{
1582-
if (const Boolean* r = dynamic_cast<const Boolean*>(rhs)) {
1547+
if (const Boolean* r = dynamic_cast<const Boolean*>(&rhs)) {
15831548
return (value() == r->value());
15841549
}
15851550
return false;
15861551
}
15871552

1588-
bool Boolean::operator== (const Expression& rhs) const
1589-
{
1590-
return operator==(&rhs);
1591-
}
1592-
1593-
bool Color::operator== (const Expression* rhs) const
1553+
bool Color::operator== (const Expression& rhs) const
15941554
{
1595-
if (const Color* r = dynamic_cast<const Color*>(rhs)) {
1555+
if (const Color* r = dynamic_cast<const Color*>(&rhs)) {
15961556
return r_ == r->r() &&
15971557
g_ == r->g() &&
15981558
b_ == r->b() &&
@@ -1601,14 +1561,9 @@ namespace Sass {
16011561
return false;
16021562
}
16031563

1604-
bool Color::operator== (const Expression& rhs) const
1605-
{
1606-
return operator==(&rhs);
1607-
}
1608-
1609-
bool List::operator== (const Expression* rhs) const
1564+
bool List::operator== (const Expression& rhs) const
16101565
{
1611-
if (const List* r = dynamic_cast<const List*>(rhs)) {
1566+
if (const List* r = dynamic_cast<const List*>(&rhs)) {
16121567
if (length() != r->length()) return false;
16131568
if (separator() != r->separator()) return false;
16141569
for (size_t i = 0, L = length(); i < L; ++i) {
@@ -1622,14 +1577,9 @@ namespace Sass {
16221577
return false;
16231578
}
16241579

1625-
bool List::operator== (const Expression& rhs) const
1626-
{
1627-
return operator==(&rhs);
1628-
}
1629-
1630-
bool Map::operator== (const Expression* rhs) const
1580+
bool Map::operator== (const Expression& rhs) const
16311581
{
1632-
if (const Map* r = dynamic_cast<const Map*>(rhs)) {
1582+
if (const Map* r = dynamic_cast<const Map*>(&rhs)) {
16331583
if (length() != r->length()) return false;
16341584
for (auto key : keys()) {
16351585
Expression* lv = at(key);
@@ -1642,19 +1592,9 @@ namespace Sass {
16421592
return false;
16431593
}
16441594

1645-
bool Map::operator== (const Expression& rhs) const
1646-
{
1647-
return operator==(&rhs);
1648-
}
1649-
1650-
bool Null::operator== (const Expression* rhs) const
1651-
{
1652-
return rhs->concrete_type() == NULL_VAL;
1653-
}
1654-
16551595
bool Null::operator== (const Expression& rhs) const
16561596
{
1657-
return operator==(&rhs);
1597+
return rhs.concrete_type() == NULL_VAL;
16581598
}
16591599

16601600
size_t List::size() const {

src/ast.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ namespace Sass {
143143
: Expression(pstate, d, e, i, ct)
144144
{ }
145145
virtual bool operator== (const Expression& rhs) const = 0;
146-
virtual bool operator== (const Expression* rhs) const = 0;
147146
virtual string to_string(bool compressed = false, int precision = 5) const = 0;
148147
};
149148
}
@@ -819,7 +818,6 @@ namespace Sass {
819818
}
820819

821820
virtual bool operator== (const Expression& rhs) const;
822-
virtual bool operator== (const Expression* rhs) const;
823821
virtual string to_string(bool compressed = false, int precision = 5) const;
824822

825823
ATTACH_OPERATIONS()
@@ -853,7 +851,6 @@ namespace Sass {
853851
}
854852

855853
virtual bool operator== (const Expression& rhs) const;
856-
virtual bool operator== (const Expression* rhs) const;
857854
virtual string to_string(bool compressed = false, int precision = 5) const;
858855

859856
ATTACH_OPERATIONS()
@@ -1213,9 +1210,7 @@ namespace Sass {
12131210
}
12141211

12151212
virtual bool operator< (const Number& rhs) const;
1216-
virtual bool operator< (const Number* rhs) const;
12171213
virtual bool operator== (const Expression& rhs) const;
1218-
virtual bool operator== (const Expression* rhs) const;
12191214
virtual string to_string(bool compressed = false, int precision = 5) const;
12201215

12211216
ATTACH_OPERATIONS()
@@ -1252,7 +1247,6 @@ namespace Sass {
12521247
}
12531248

12541249
virtual bool operator== (const Expression& rhs) const;
1255-
virtual bool operator== (const Expression* rhs) const;
12561250
virtual string to_string(bool compressed = false, int precision = 5) const;
12571251

12581252
ATTACH_OPERATIONS()
@@ -1268,7 +1262,6 @@ namespace Sass {
12681262
: Value(pstate), message_(msg)
12691263
{ concrete_type(C_ERROR); }
12701264
virtual bool operator== (const Expression& rhs) const;
1271-
virtual bool operator== (const Expression* rhs) const;
12721265
virtual string to_string(bool compressed = false, int precision = 5) const;
12731266
ATTACH_OPERATIONS()
12741267
};
@@ -1283,7 +1276,6 @@ namespace Sass {
12831276
: Value(pstate), message_(msg)
12841277
{ concrete_type(C_WARNING); }
12851278
virtual bool operator== (const Expression& rhs) const;
1286-
virtual bool operator== (const Expression* rhs) const;
12871279
virtual string to_string(bool compressed = false, int precision = 5) const;
12881280
ATTACH_OPERATIONS()
12891281
};
@@ -1313,7 +1305,6 @@ namespace Sass {
13131305
}
13141306

13151307
virtual bool operator== (const Expression& rhs) const;
1316-
virtual bool operator== (const Expression* rhs) const;
13171308
virtual string to_string(bool compressed = false, int precision = 5) const;
13181309

13191310
ATTACH_OPERATIONS()
@@ -1332,7 +1323,6 @@ namespace Sass {
13321323
static string type_name() { return "string"; }
13331324
virtual ~String() = 0;
13341325
virtual bool operator==(const Expression& rhs) const = 0;
1335-
virtual bool operator==(const Expression* rhs) const = 0;
13361326
virtual string to_string(bool compressed = false, int precision = 5) const = 0;
13371327
ATTACH_OPERATIONS()
13381328
};
@@ -1362,7 +1352,6 @@ namespace Sass {
13621352
}
13631353

13641354
virtual bool operator==(const Expression& rhs) const;
1365-
virtual bool operator==(const Expression* rhs) const;
13661355
virtual string to_string(bool compressed = false, int precision = 5) const;
13671356

13681357
ATTACH_OPERATIONS()
@@ -1402,7 +1391,6 @@ namespace Sass {
14021391
}
14031392

14041393
virtual bool operator==(const Expression& rhs) const;
1405-
virtual bool operator==(const Expression* rhs) const;
14061394
virtual string to_string(bool compressed = false, int precision = 5) const;
14071395

14081396
// static char auto_quote() { return '*'; }
@@ -1423,7 +1411,6 @@ namespace Sass {
14231411
value_ = unquote(value_, &quote_mark_);
14241412
}
14251413
virtual bool operator==(const Expression& rhs) const;
1426-
virtual bool operator==(const Expression* rhs) const;
14271414
virtual string to_string(bool compressed = false, int precision = 5) const;
14281415
ATTACH_OPERATIONS()
14291416
};
@@ -1589,7 +1576,6 @@ namespace Sass {
15891576
}
15901577

15911578
virtual bool operator== (const Expression& rhs) const;
1592-
virtual bool operator== (const Expression* rhs) const;
15931579
virtual string to_string(bool compressed = false, int precision = 5) const;
15941580

15951581
ATTACH_OPERATIONS()

0 commit comments

Comments
 (0)