Skip to content

Commit 32c6925

Browse files
committed
Further performance improvements (0.88)
1 parent 483d611 commit 32c6925

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2190
-1929
lines changed

Makefile.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ HPPFILES = \
88
ast.hpp \
99
ast2c.hpp \
1010
ast_css.hpp \
11+
ast_base.hpp \
1112
ast_def_macros.hpp \
1213
ast_fwd_decl.hpp \
1314
ast_helpers.hpp \
1415
ast_selectors.hpp \
16+
ast_containers.hpp \
1517
ast_supports.hpp \
1618
ast_values.hpp \
1719
backtrace.hpp \
@@ -176,7 +178,6 @@ SOURCES = \
176178
source_state.cpp \
177179
source_span.cpp \
178180
error_handling.cpp \
179-
MurmurHash2.cpp \
180181
memory/allocator.cpp \
181182
memory/shared_ptr.cpp \
182183
LUrlParser/LUrlParser.cpp \

include/sass/base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ enum Sass_Output_Style {
6868
SASS_STYLE_COMPRESSED,
6969
// only used internaly
7070
SASS_STYLE_INSPECT,
71-
SASS_STYLE_TO_SASS,
7271
SASS_STYLE_TO_CSS
7372
};
7473

src/MurmurHash2.cpp

Whitespace-only changes.

src/ast.cpp

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Sass {
1212

13-
// static Null sass_null(SourceSpan::fake("null"));
13+
// static Null sass_null(SourceSpan("null"));
1414

1515
uint8_t sass_op_to_precedence(enum Sass_OP op) {
1616
switch (op) {
@@ -137,15 +137,14 @@ namespace Sass {
137137
/////////////////////////////////////////////////////////////////////////
138138

139139
Statement::Statement(const SourceSpan& pstate, size_t t)
140-
: AST_Node(pstate), tabs_(t), group_end_(false)
140+
: AST_Node(pstate), tabs_(t)
141141
{ }
142142
Statement::Statement(SourceSpan&& pstate, size_t t)
143-
: AST_Node(std::move(pstate)), tabs_(t), group_end_(false)
143+
: AST_Node(std::move(pstate)), tabs_(t)
144144
{ }
145145
Statement::Statement(const Statement* ptr)
146146
: AST_Node(ptr),
147-
tabs_(ptr->tabs_),
148-
group_end_(ptr->group_end_)
147+
tabs_(ptr->tabs_)
149148
{ }
150149

151150
bool Statement::bubbles() const
@@ -168,19 +167,19 @@ namespace Sass {
168167

169168
Block::Block(const SourceSpan& pstate, size_t s, bool r)
170169
: Statement(pstate),
171-
Vectorized<Statement>(s),
170+
VectorizedBase<Statement>(s),
172171
idxs_(0), is_root_(r)
173172
{ }
174173

175174
Block::Block(const SourceSpan& pstate, const sass::vector<StatementObj>& vec, bool r) :
176175
Statement(pstate),
177-
Vectorized<Statement>(vec),
176+
VectorizedBase<Statement>(vec),
178177
idxs_(0), is_root_(r)
179178
{ }
180179

181180
Block::Block(const SourceSpan& pstate, sass::vector<StatementObj>&& vec, bool r) :
182181
Statement(pstate),
183-
Vectorized<Statement>(std::move(vec)),
182+
VectorizedBase<Statement>(std::move(vec)),
184183
idxs_(0), is_root_(r)
185184
{ }
186185

@@ -250,7 +249,7 @@ namespace Sass {
250249
/////////////////////////////////////////////////////////////////////////
251250

252251
Bubble::Bubble(const SourceSpan& pstate, Statement_Obj n, Statement_Obj g, size_t t)
253-
: Statement(pstate, t), node_(n), group_end_(g == nullptr)
252+
: Statement(pstate, t), node_(n)
254253
{ }
255254

256255
bool Bubble::bubbles() const
@@ -363,7 +362,7 @@ namespace Sass {
363362
ImportRule::ImportRule(
364363
const SourceSpan& pstate) :
365364
Statement(pstate),
366-
Vectorized()
365+
VectorizedBase()
367366
{}
368367

369368
/////////////////////////////////////////////////////////////////////////
@@ -499,24 +498,43 @@ namespace Sass {
499498
/////////////////////////////////////////////////////////////////////////
500499
/////////////////////////////////////////////////////////////////////////
501500

502-
Expression::Expression(const SourceSpan& pstate, bool d, bool e, bool i, Type ct)
503-
: SassNode(pstate),
504-
concrete_type_(ct)
501+
Interpolant::Interpolant(const SourceSpan& pstate)
502+
: AST_Node(pstate)
505503
{ }
506504

507-
Expression::Expression(SourceSpan&& pstate, bool d, bool e, bool i, Type ct)
508-
: SassNode(std::move(pstate)),
509-
concrete_type_(ct)
505+
bool Interpolant::operator==(const Interpolant & rhs) const
506+
{
507+
if (const Expression* ex = Cast<Expression>(&rhs)) {
508+
return *this == *ex;
509+
}
510+
else if (const ItplString* str = Cast<ItplString>(&rhs)) {
511+
return *this == *str;
512+
}
513+
return false;
514+
}
515+
516+
Interpolant::Interpolant(SourceSpan&& pstate)
517+
: AST_Node(std::move(pstate))
510518
{ }
511519

512-
Expression::Expression(const Expression* ptr)
513-
: SassNode(ptr),
514-
concrete_type_(ptr->concrete_type_)
520+
Interpolant::Interpolant(const Interpolant* ptr)
521+
: AST_Node(ptr)
515522
{ }
516523

517-
SassNode::SassNode(const SassNode* ptr) :
518-
AST_Node(ptr)
519-
{};
524+
/////////////////////////////////////////////////////////////////////////
525+
/////////////////////////////////////////////////////////////////////////
526+
527+
Expression::Expression(const SourceSpan& pstate, bool d, bool e, bool i)
528+
: Interpolant(pstate)
529+
{ }
530+
531+
Expression::Expression(SourceSpan&& pstate, bool d, bool e, bool i)
532+
: Interpolant(std::move(pstate))
533+
{ }
534+
535+
Expression::Expression(const Expression* ptr)
536+
: Interpolant(ptr)
537+
{ }
520538

521539
/////////////////////////////////////////////////////////////////////////
522540
/////////////////////////////////////////////////////////////////////////
@@ -552,14 +570,6 @@ namespace Sass {
552570
{
553571
}
554572

555-
size_t Argument::hash() const
556-
{
557-
if (hash_ == 0) {
558-
hash_start(hash_, name().hash());
559-
hash_combine(hash_, value()->hash());
560-
}
561-
return hash_;
562-
}
563573

564574
/////////////////////////////////////////////////////////////////////////
565575
/////////////////////////////////////////////////////////////////////////
@@ -604,15 +614,9 @@ namespace Sass {
604614
}
605615

606616
// Returns whether [this] excludes [node].
607-
bool AtRootQuery::excludes(Statement* node) const
617+
bool AtRootQuery::excludes(CssParentNode* node) const
608618
{
609619
if (all()) return !include();
610-
if (!Cast<CssMediaRule>(node)) {
611-
if (!Cast<CssParentNode>(node)) {
612-
std::cerr << "has non CssParentNode\n";
613-
debug_ast(node);
614-
}
615-
}
616620
if (rule() && Cast<CssStyleRule>(node)) return !include();
617621
return excludesName(_nameFor(node));
618622
}
@@ -726,7 +730,7 @@ namespace Sass {
726730
const EnvKeyFlatMap<ExpressionObj>& named,
727731
Expression* restArg,
728732
Expression* kwdRest) :
729-
SassNode(pstate),
733+
AST_Node(pstate),
730734
positional_(positional),
731735
named_(named),
732736
restArg_(restArg),
@@ -775,7 +779,7 @@ namespace Sass {
775779
/////////////////////////////////////////////////////////////////////////
776780
/////////////////////////////////////////////////////////////////////////
777781

778-
ArgumentResults2::ArgumentResults2(
782+
ArgumentResults::ArgumentResults(
779783
const sass::vector<ValueObj>& positional,
780784
const EnvKeyFlatMap<ValueObj>& named,
781785
Sass_Separator separator) :
@@ -785,8 +789,8 @@ namespace Sass {
785789
{
786790
}
787791

788-
ArgumentResults2::ArgumentResults2(
789-
sass::vector<ValueObj> && positional,
792+
ArgumentResults::ArgumentResults(
793+
sass::vector<ValueObj>&& positional,
790794
EnvKeyFlatMap<ValueObj>&& named,
791795
Sass_Separator separator) :
792796
positional_(std::move(positional)),
@@ -795,23 +799,23 @@ namespace Sass {
795799
{
796800
}
797801

798-
ArgumentResults2::ArgumentResults2(
799-
const ArgumentResults2& other) :
802+
ArgumentResults::ArgumentResults(
803+
const ArgumentResults& other) :
800804
positional_(other.positional_),
801805
named_(other.named_),
802806
separator_(other.separator_)
803807
{
804808
}
805809

806-
ArgumentResults2::ArgumentResults2(
807-
ArgumentResults2&& other) noexcept :
810+
ArgumentResults::ArgumentResults(
811+
ArgumentResults&& other) noexcept :
808812
positional_(std::move(other.positional_)),
809813
named_(std::move(other.named_)),
810814
separator_(other.separator_)
811815
{
812816
}
813817

814-
ArgumentResults2& ArgumentResults2::operator=(ArgumentResults2&& other) noexcept {
818+
ArgumentResults& ArgumentResults::operator=(ArgumentResults&& other) noexcept {
815819
positional_ = std::move(other.positional_);
816820
named_ = std::move(other.named_);
817821
separator_ = other.separator_;
@@ -822,7 +826,7 @@ namespace Sass {
822826
const SourceSpan& pstate,
823827
const sass::vector<ArgumentObj>& arguments,
824828
const sass::string& restArg) :
825-
SassNode(pstate),
829+
AST_Node(pstate),
826830
arguments_(arguments),
827831
restArg_(restArg)
828832
{
@@ -860,8 +864,8 @@ namespace Sass {
860864
while (i < std::min(positional, iL)) {
861865
if (names.count(arguments_[i]->name()) == 1) {
862866
throw Exception::InvalidSyntax(arguments_[i]->pstate(), traces,
863-
"Argument " + arguments_[i]->name().orig() + " name was passed both by position and by "
864-
"name.");
867+
"Argument " + arguments_[i]->name().orig() +
868+
" name was passed both by position and by name.");
865869
}
866870
i++;
867871
}
@@ -899,7 +903,7 @@ namespace Sass {
899903
// sass::sstream strm;
900904
// strm << "No " << pluralize("argument", unknownNames.size());
901905
// strm << " named " << toSentence(unknownNames, "or");
902-
throw Exception::InvalidSyntax(SourceSpan::fake("[pstate77]"), traces,
906+
throw Exception::InvalidSyntax(SourceSpan("[pstate77]"), traces,
903907
"No argument named " + toSentence(unknownNames, "or") + ".");
904908
}
905909

@@ -929,15 +933,6 @@ namespace Sass {
929933
return true;
930934
}
931935

932-
sass::string ArgumentDeclaration::toString2() const
933-
{
934-
sass::vector<sass::string> results;
935-
for (Argument* argument : arguments_) { // XXXXXXXXXXXYYYYYYY
936-
results.emplace_back(argument->name().orig());
937-
}
938-
return Util::join_strings(results, ", ");
939-
}
940-
941936
CallableDeclaration::CallableDeclaration(
942937
const SourceSpan& pstate,
943938
const EnvKey& name,
@@ -1051,7 +1046,7 @@ namespace Sass {
10511046
const sass::string& name,
10521047
ArgumentDeclaration* parameters,
10531048
Sass_Function_Entry function) :
1054-
Callable(SourceSpan::fake("[external]")),
1049+
Callable(SourceSpan("[external]")),
10551050
name_(name),
10561051
declaration_(parameters),
10571052
function_(function)

0 commit comments

Comments
 (0)