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

Commit 2c577fc

Browse files
committed
Remove unused and unreference code path
1 parent 509e2be commit 2c577fc

File tree

5 files changed

+13
-87
lines changed

5 files changed

+13
-87
lines changed

src/ast.cpp

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,13 @@ namespace Sass {
4848
{
4949
value_ = str_rtrim(value_);
5050
}
51-
void String_Constant::ltrim()
52-
{
53-
value_ = str_ltrim(value_);
54-
}
55-
void String_Constant::trim()
56-
{
57-
rtrim();
58-
ltrim();
59-
}
6051

6152
void String_Schema::rtrim()
6253
{
6354
if (!empty()) {
6455
if (String_Ptr str = Cast<String>(last())) str->rtrim();
6556
}
6657
}
67-
void String_Schema::ltrim()
68-
{
69-
if (!empty()) {
70-
if (String_Ptr str = Cast<String>(first())) str->ltrim();
71-
}
72-
}
73-
void String_Schema::trim()
74-
{
75-
rtrim();
76-
ltrim();
77-
}
7858

7959
void Argument::set_delayed(bool delayed)
8060
{
@@ -124,11 +104,6 @@ namespace Sass {
124104
pstate_.offset += pstate - pstate_ + pstate.offset;
125105
}
126106

127-
void AST_Node::set_pstate_offset(const Offset& offset)
128-
{
129-
pstate_.offset = offset;
130-
}
131-
132107
bool Simple_Selector::is_ns_eq(const Simple_Selector& r) const
133108
{
134109
// https://github.com/sass/sass/issues/2229
@@ -655,9 +630,8 @@ namespace Sass {
655630
{
656631
return *this == *w;
657632
}
658-
if (is_ns_eq(rhs))
659-
{ return name() == rhs.name(); }
660-
return ns() == rhs.ns();
633+
return is_ns_eq(rhs) &&
634+
name() == rhs.name();
661635
}
662636

663637
bool Pseudo_Selector::operator== (const Pseudo_Selector& rhs) const
@@ -678,9 +652,8 @@ namespace Sass {
678652
{
679653
return *this == *w;
680654
}
681-
if (is_ns_eq(rhs))
682-
{ return name() == rhs.name(); }
683-
return ns() == rhs.ns();
655+
return is_ns_eq(rhs) &&
656+
name() == rhs.name();
684657
}
685658

686659
bool Pseudo_Selector::operator< (const Pseudo_Selector& rhs) const
@@ -721,9 +694,8 @@ namespace Sass {
721694
{
722695
return *this == *w;
723696
}
724-
if (is_ns_eq(rhs))
725-
{ return name() == rhs.name(); }
726-
return ns() == rhs.ns();
697+
return is_ns_eq(rhs) &&
698+
name() == rhs.name();
727699
}
728700

729701
bool Wrapped_Selector::operator< (const Wrapped_Selector& rhs) const
@@ -754,10 +726,8 @@ namespace Sass {
754726
if (Selector_List_Obj lhs_list = Cast<Selector_List>(selector())) {
755727
return lhs_list->is_superselector_of(rhs_list);
756728
}
757-
error("is_superselector expected a Selector_List", sub->pstate());
758-
} else {
759-
error("is_superselector expected a Selector_List", sub->pstate());
760729
}
730+
error("is_superselector expected a Selector_List", sub->pstate());
761731
return false;
762732
}
763733

@@ -1095,15 +1065,6 @@ namespace Sass {
10951065
return 1 + tail()->length();
10961066
}
10971067

1098-
Complex_Selector_Obj Complex_Selector::context(Context& ctx)
1099-
{
1100-
if (!tail()) return 0;
1101-
if (!head()) return tail()->context(ctx);
1102-
Complex_Selector_Obj cpy = SASS_MEMORY_NEW(Complex_Selector, pstate(), combinator(), head(), tail()->context(ctx));
1103-
cpy->media_block(media_block());
1104-
return cpy;
1105-
}
1106-
11071068
// append another complex selector at the end
11081069
// check if we need to append some headers
11091070
// then we need to check for the combinator
@@ -1611,14 +1572,6 @@ namespace Sass {
16111572
}
16121573
};
16131574

1614-
std::vector<std::string> Compound_Selector::to_str_vec()
1615-
{
1616-
std::vector<std::string> result(length());
1617-
for (size_t i = 0, L = length(); i < L; ++i)
1618-
{ result.push_back((*this)[i]->to_string()); }
1619-
return result;
1620-
}
1621-
16221575
void Compound_Selector::append(Simple_Selector_Ptr element)
16231576
{
16241577
Vectorized<Simple_Selector_Obj>::append(element);
@@ -2105,21 +2058,6 @@ namespace Sass {
21052058
return false;
21062059
}
21072060

2108-
bool Number::eq (const Expression& rhs) const
2109-
{
2110-
if (Number_Ptr_Const r = Cast<Number>(&rhs)) {
2111-
size_t lhs_units = numerator_units_.size() + denominator_units_.size();
2112-
size_t rhs_units = r->numerator_units_.size() + r->denominator_units_.size();
2113-
if (!lhs_units && !rhs_units) {
2114-
return std::fabs(value() - r->value()) < NUMBER_EPSILON;
2115-
}
2116-
return (numerator_units_ == r->numerator_units_) &&
2117-
(denominator_units_ == r->denominator_units_) &&
2118-
std::fabs(value() - r->value()) < NUMBER_EPSILON;
2119-
}
2120-
return false;
2121-
}
2122-
21232061
bool Number::operator== (const Expression& rhs) const
21242062
{
21252063
if (Number_Ptr_Const r = Cast<Number>(&rhs)) {

src/ast.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ namespace Sass {
126126
virtual void cloneChildren() {};
127127
public:
128128
void update_pstate(const ParserState& pstate);
129-
void set_pstate_offset(const Offset& offset);
130129
public:
131130
Offset off() { return pstate(); }
132131
Position pos() { return pstate(); }
@@ -1638,7 +1637,6 @@ namespace Sass {
16381637

16391638
virtual bool operator< (const Number& rhs) const;
16401639
virtual bool operator== (const Expression& rhs) const;
1641-
virtual bool eq(const Expression& rhs) const;
16421640
ATTACH_AST_OPERATIONS(Number)
16431641
ATTACH_OPERATIONS()
16441642
};
@@ -1771,8 +1769,6 @@ namespace Sass {
17711769
static std::string type_name() { return "string"; }
17721770
virtual ~String() = 0;
17731771
virtual void rtrim() = 0;
1774-
virtual void ltrim() = 0;
1775-
virtual void trim() = 0;
17761772
virtual bool operator==(const Expression& rhs) const = 0;
17771773
virtual bool operator<(const Expression& rhs) const {
17781774
return this->to_string() < rhs.to_string();
@@ -1812,8 +1808,6 @@ namespace Sass {
18121808
return false;
18131809
}
18141810
virtual void rtrim();
1815-
virtual void ltrim();
1816-
virtual void trim();
18171811

18181812
virtual size_t hash()
18191813
{
@@ -1866,8 +1860,6 @@ namespace Sass {
18661860
static std::string type_name() { return "string"; }
18671861
virtual bool is_invisible() const;
18681862
virtual void rtrim();
1869-
virtual void ltrim();
1870-
virtual void trim();
18711863

18721864
virtual size_t hash()
18731865
{
@@ -2812,7 +2804,6 @@ namespace Sass {
28122804
return length() == 1 &&
28132805
Cast<Parent_Selector>((*this)[0]);
28142806
}
2815-
SubSetMapKeys to_str_vec(); // sometimes need to convert to a flat "by-value" data structure
28162807

28172808
virtual bool operator<(const Compound_Selector& rhs) const;
28182809
virtual bool operator==(const Compound_Selector& rhs) const;
@@ -2886,9 +2877,6 @@ namespace Sass {
28862877
combinator() == Combinator::ANCESTOR_OF;
28872878
}
28882879

2889-
Complex_Selector_Obj context(Context&);
2890-
2891-
28922880
Selector_List_Ptr tails(Context& ctx, Selector_List_Ptr tails);
28932881

28942882
// front returns the first real tail

src/expand.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ namespace Sass {
4141
backtrace_stack.push_back(bt);
4242
}
4343

44-
Context& Expand::context()
45-
{
46-
return ctx;
47-
}
48-
4944
Env* Expand::environment()
5045
{
5146
if (env_stack.size() > 0)

src/expand.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace Sass {
1919
public:
2020

2121
Env* environment();
22-
Context& context();
2322
Selector_List_Obj selector();
2423
Backtrace* backtrace();
2524

src/parser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ namespace Sass {
10161016
}
10171017

10181018
// parse +/- and return false if negative
1019+
// this is never hit via spec tests
10191020
bool Parser::parse_number_prefix()
10201021
{
10211022
bool positive = true;
@@ -1420,6 +1421,7 @@ namespace Sass {
14201421
if (ex && ex->operand()) ex->is_delayed(ex->operand()->is_delayed());
14211422
return ex;
14221423
}
1424+
// this whole branch is never hit via spec tests
14231425
else if (peek < sequence < one_plus < alternatives < css_whitespace, exactly<'-'>, exactly<'+'> > >, number > >()) {
14241426
if (parse_number_prefix()) return parse_value(); // prefix is positive
14251427
Unary_Expression_Ptr ex = SASS_MEMORY_NEW(Unary_Expression, pstate, Unary_Expression::MINUS, parse_value());
@@ -2238,6 +2240,8 @@ namespace Sass {
22382240

22392241
if (lexed == "@else") error("Invalid CSS: @else must come after @if", pstate);
22402242

2243+
// this whole branch is never hit via spec tests
2244+
22412245
Directive_Ptr at_rule = SASS_MEMORY_NEW(Directive, pstate, kwd);
22422246
Lookahead lookahead = lookahead_for_include(position);
22432247
if (lookahead.found && !lookahead.has_interpolants) {
@@ -2261,6 +2265,7 @@ namespace Sass {
22612265
return at_rule;
22622266
}
22632267

2268+
// this whole branch is never hit via spec tests
22642269
Directive_Obj Parser::parse_prefixed_directive()
22652270
{
22662271
std::string kwd(lexed);
@@ -2696,6 +2701,7 @@ namespace Sass {
26962701
if (String_Schema_Ptr schema = Cast<String_Schema>(operands[i])) {
26972702
if (schema->has_interpolants()) {
26982703
if (i + 1 < S) {
2704+
// this whole branch is never hit via spec tests
26992705
Expression_Obj rhs = fold_operands(operands[i+1], operands, ops, i + 2);
27002706
rhs = SASS_MEMORY_NEW(Binary_Expression, base->pstate(), ops[i], schema, rhs);
27012707
base = SASS_MEMORY_NEW(Binary_Expression, base->pstate(), ops[i], base, rhs);

0 commit comments

Comments
 (0)