Skip to content

Commit 9df83e1

Browse files
glebmxzyfer
authored andcommitted
Do not use 0 for initializing SharedImpl
This is more readable and will later on allow us to initialized SharedImpl directly from T*, avoiding a redundant temporary SharedImpl construction.
1 parent 546f8e9 commit 9df83e1

File tree

13 files changed

+144
-144
lines changed

13 files changed

+144
-144
lines changed

src/ast.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ namespace Sass {
807807
return ns() < rhs.ns();
808808
}
809809

810-
bool Wrapped_Selector::is_superselector_of(Wrapped_Selector_Obj sub) const
810+
bool Wrapped_Selector::is_superselector_of(Wrapped_Selector_Ptr_Const sub) const
811811
{
812812
if (this->name() != sub->name()) return false;
813813
if (this->name() == ":current") return false;
@@ -820,21 +820,21 @@ namespace Sass {
820820
return false;
821821
}
822822

823-
bool Compound_Selector::is_superselector_of(Selector_List_Obj rhs, std::string wrapped) const
823+
bool Compound_Selector::is_superselector_of(Selector_List_Ptr_Const rhs, std::string wrapped) const
824824
{
825825
for (Complex_Selector_Obj item : rhs->elements()) {
826826
if (is_superselector_of(item, wrapped)) return true;
827827
}
828828
return false;
829829
}
830830

831-
bool Compound_Selector::is_superselector_of(Complex_Selector_Obj rhs, std::string wrapped) const
831+
bool Compound_Selector::is_superselector_of(Complex_Selector_Ptr_Const rhs, std::string wrapped) const
832832
{
833833
if (rhs->head()) return is_superselector_of(rhs->head(), wrapped);
834834
return false;
835835
}
836836

837-
bool Compound_Selector::is_superselector_of(Compound_Selector_Obj rhs, std::string wrapping) const
837+
bool Compound_Selector::is_superselector_of(Compound_Selector_Ptr_Const rhs, std::string wrapping) const
838838
{
839839
Compound_Selector_Ptr_Const lhs = this;
840840
Simple_Selector_Ptr lbase = lhs->base();
@@ -895,7 +895,7 @@ namespace Sass {
895895
if (wrapped->name() == ":matches" || wrapped->name() == ":-moz-any") {
896896
wlhs = wrapped->selector();
897897
if (Selector_List_Obj list = Cast<Selector_List>(wrapped->selector())) {
898-
if (Compound_Selector_Obj comp = Cast<Compound_Selector>(rhs)) {
898+
if (Compound_Selector_Ptr_Const comp = Cast<Compound_Selector>(rhs)) {
899899
if (!wrapping.empty() && wrapping != wrapped->name()) return false;
900900
if (wrapping.empty() || wrapping != wrapped->name()) {;
901901
if (list->is_superselector_of(comp, wrapped->name())) return true;
@@ -956,7 +956,7 @@ namespace Sass {
956956
pstate(),
957957
Complex_Selector::ANCESTOR_OF,
958958
this,
959-
0);
959+
{});
960960
}
961961

962962
Selector_List_Ptr Complex_Selector::unify_with(Complex_Selector_Ptr other)
@@ -997,7 +997,7 @@ namespace Sass {
997997
if (is_universal)
998998
{
999999
// move the head
1000-
l_last->head(0);
1000+
l_last->head({});
10011001
r_last->head(unified);
10021002
}
10031003

@@ -1059,12 +1059,12 @@ namespace Sass {
10591059
// there is no break?!
10601060
}
10611061

1062-
bool Complex_Selector::is_superselector_of(Compound_Selector_Obj rhs, std::string wrapping) const
1062+
bool Complex_Selector::is_superselector_of(Compound_Selector_Ptr_Const rhs, std::string wrapping) const
10631063
{
10641064
return last()->head() && last()->head()->is_superselector_of(rhs, wrapping);
10651065
}
10661066

1067-
bool Complex_Selector::is_superselector_of(Complex_Selector_Obj rhs, std::string wrapping) const
1067+
bool Complex_Selector::is_superselector_of(Complex_Selector_Ptr_Const rhs, std::string wrapping) const
10681068
{
10691069
Complex_Selector_Ptr_Const lhs = this;
10701070
// check for selectors with leading or trailing combinators
@@ -1098,7 +1098,7 @@ namespace Sass {
10981098
}
10991099

11001100
bool found = false;
1101-
Complex_Selector_Obj marker = rhs;
1101+
Complex_Selector_Ptr_Const marker = rhs;
11021102
for (size_t i = 0, L = rhs->length(); i < L; ++i) {
11031103
if (i == L-1)
11041104
{ return false; }
@@ -1297,7 +1297,7 @@ namespace Sass {
12971297
h->erase(h->begin());
12981298
ss->head(h);
12991299
} else {
1300-
ss->head(NULL);
1300+
ss->head({});
13011301
}
13021302
// adjust for parent selector (1 char)
13031303
// if (h->length()) {
@@ -1334,7 +1334,7 @@ namespace Sass {
13341334
h->erase(h->begin());
13351335
ss->head(h);
13361336
} else {
1337-
ss->head(NULL);
1337+
ss->head({});
13381338
}
13391339
// \/ IMO ruby sass bug \/
13401340
ss->has_line_feed(false);
@@ -1362,7 +1362,7 @@ namespace Sass {
13621362
cpy->head(SASS_MEMORY_NEW(Compound_Selector, head->pstate()));
13631363
for (size_t i = 1, L = this->head()->length(); i < L; ++i)
13641364
cpy->head()->append((*this->head())[i]);
1365-
if (!cpy->head()->length()) cpy->head(0);
1365+
if (!cpy->head()->length()) cpy->head({});
13661366
retval->append(cpy->skip_empty_reference());
13671367
}
13681368
}
@@ -1372,7 +1372,7 @@ namespace Sass {
13721372
cpy->head(SASS_MEMORY_NEW(Compound_Selector, head->pstate()));
13731373
for (size_t i = 1, L = this->head()->length(); i < L; ++i)
13741374
cpy->head()->append((*this->head())[i]);
1375-
if (!cpy->head()->length()) cpy->head(0);
1375+
if (!cpy->head()->length()) cpy->head({});
13761376
retval->append(cpy->skip_empty_reference());
13771377
}
13781378
}
@@ -1461,8 +1461,8 @@ namespace Sass {
14611461
Complex_Selector::Combinator Complex_Selector::clear_innermost()
14621462
{
14631463
Combinator c;
1464-
if (!tail() || tail()->tail() == 0)
1465-
{ c = combinator(); combinator(ANCESTOR_OF); tail(0); }
1464+
if (!tail() || tail()->tail() == nullptr)
1465+
{ c = combinator(); combinator(ANCESTOR_OF); tail({}); }
14661466
else
14671467
{ c = tail_->clear_innermost(); }
14681468
return c;
@@ -1590,7 +1590,7 @@ namespace Sass {
15901590

15911591
// it's a superselector if every selector of the right side
15921592
// list is a superselector of the given left side selector
1593-
bool Complex_Selector::is_superselector_of(Selector_List_Obj sub, std::string wrapping) const
1593+
bool Complex_Selector::is_superselector_of(Selector_List_Ptr_Const sub, std::string wrapping) const
15941594
{
15951595
// Check every rhs selector against left hand list
15961596
for(size_t i = 0, L = sub->length(); i < L; ++i) {
@@ -1601,7 +1601,7 @@ namespace Sass {
16011601

16021602
// it's a superselector if every selector of the right side
16031603
// list is a superselector of the given left side selector
1604-
bool Selector_List::is_superselector_of(Selector_List_Obj sub, std::string wrapping) const
1604+
bool Selector_List::is_superselector_of(Selector_List_Ptr_Const sub, std::string wrapping) const
16051605
{
16061606
// Check every rhs selector against left hand list
16071607
for(size_t i = 0, L = sub->length(); i < L; ++i) {
@@ -1612,7 +1612,7 @@ namespace Sass {
16121612

16131613
// it's a superselector if every selector on the right side
16141614
// is a superselector of any one of the left side selectors
1615-
bool Selector_List::is_superselector_of(Compound_Selector_Obj sub, std::string wrapping) const
1615+
bool Selector_List::is_superselector_of(Compound_Selector_Ptr_Const sub, std::string wrapping) const
16161616
{
16171617
// Check every lhs selector against right hand
16181618
for(size_t i = 0, L = length(); i < L; ++i) {
@@ -1623,7 +1623,7 @@ namespace Sass {
16231623

16241624
// it's a superselector if every selector on the right side
16251625
// is a superselector of any one of the left side selectors
1626-
bool Selector_List::is_superselector_of(Complex_Selector_Obj sub, std::string wrapping) const
1626+
bool Selector_List::is_superselector_of(Complex_Selector_Ptr_Const sub, std::string wrapping) const
16271627
{
16281628
// Check every lhs selector against right hand
16291629
for(size_t i = 0, L = length(); i < L; ++i) {
@@ -1736,7 +1736,7 @@ namespace Sass {
17361736
}
17371737
}
17381738
}
1739-
return NULL;
1739+
return {};
17401740
}
17411741

17421742
Argument_Obj Arguments::get_keyword_argument()
@@ -1748,7 +1748,7 @@ namespace Sass {
17481748
}
17491749
}
17501750
}
1751-
return NULL;
1751+
return {};
17521752
}
17531753

17541754
void Arguments::adjust_after_pushing(Argument_Obj a)
@@ -2034,7 +2034,7 @@ namespace Sass {
20342034
{
20352035
if (elements_.count(k))
20362036
{ return elements_.at(k); }
2037-
else { return NULL; }
2037+
else { return {}; }
20382038
}
20392039

20402040
bool Binary_Expression::is_left_interpolant(void) const
@@ -2096,7 +2096,7 @@ namespace Sass {
20962096
}
20972097

20982098
Function_Call::Function_Call(ParserState pstate, std::string n, Arguments_Obj args, void* cookie)
2099-
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), func_(0), via_call_(false), cookie_(cookie), hash_(0)
2099+
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), func_(), via_call_(false), cookie_(cookie), hash_(0)
21002100
{ concrete_type(FUNCTION); }
21012101
Function_Call::Function_Call(ParserState pstate, std::string n, Arguments_Obj args, Function_Obj func)
21022102
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), func_(func), via_call_(false), cookie_(0), hash_(0)

0 commit comments

Comments
 (0)