Skip to content

Commit ce63c19

Browse files
committed
Add CompoundSelectorSet (shared obj instead of stack obj)
1 parent 121a43e commit ce63c19

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/ast_fwd_decl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ namespace Sass {
410410
typedef std::deque<Complex_Selector_Obj> ComplexSelectorDeque;
411411
typedef std::set<Simple_Selector_Obj, OrderNodes> SimpleSelectorSet;
412412
typedef std::set<Complex_Selector_Obj, OrderNodes> ComplexSelectorSet;
413+
typedef std::set<Compound_Selector_Obj, OrderNodes> CompoundSelectorSet;
413414
typedef std::unordered_set<Simple_Selector_Obj, HashNodes, CompareNodes> SimpleSelectorDict;
414415

415416
// ###########################################################################

src/extend.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ namespace Sass {
15131513
return pSelector;
15141514
}
15151515
};
1516-
Node Extend::extendCompoundSelector(Compound_Selector_Ptr pSelector, std::set<Compound_Selector>& seen, bool isReplace) {
1516+
Node Extend::extendCompoundSelector(Compound_Selector_Ptr pSelector, CompoundSelectorSet& seen, bool isReplace) {
15171517

15181518
DEBUG_EXEC(EXTEND_COMPOUND, printCompoundSelector(pSelector, "EXTEND COMPOUND: "))
15191519
// TODO: Ruby has another loop here to skip certain members?
@@ -1638,13 +1638,13 @@ namespace Sass {
16381638

16391639

16401640
// RUBY??: next [] if seen.include?(sels)
1641-
if (seen.find(*pSels) != seen.end()) {
1641+
if (seen.find(pSels) != seen.end()) {
16421642
continue;
16431643
}
16441644

16451645

1646-
std::set<Compound_Selector> recurseSeen(seen);
1647-
recurseSeen.insert(*pSels);
1646+
CompoundSelectorSet recurseSeen(seen);
1647+
recurseSeen.insert(pSels);
16481648

16491649

16501650
DEBUG_PRINTLN(EXTEND_COMPOUND, "RECURSING DO EXTEND: " << complexSelectorToNode(pNewSelector))
@@ -1673,7 +1673,7 @@ namespace Sass {
16731673

16741674

16751675
// check if selector has something to be extended by subset_map
1676-
bool Extend::complexSelectorHasExtension(Complex_Selector_Ptr pComplexSelector, std::set<Compound_Selector>& seen) {
1676+
bool Extend::complexSelectorHasExtension(Complex_Selector_Ptr pComplexSelector, CompoundSelectorSet& seen) {
16771677

16781678
bool hasExtension = false;
16791679

@@ -1729,7 +1729,7 @@ namespace Sass {
17291729
the combinator and compound selector are one unit
17301730
next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence)
17311731
*/
1732-
Node Extend::extendComplexSelector(Complex_Selector_Ptr pComplexSelector, std::set<Compound_Selector>& seen, bool isReplace, bool isOriginal) {
1732+
Node Extend::extendComplexSelector(Complex_Selector_Ptr pComplexSelector, CompoundSelectorSet& seen, bool isReplace, bool isOriginal) {
17331733

17341734
Node complexSelector = complexSelectorToNode(pComplexSelector);
17351735
DEBUG_PRINTLN(EXTEND_COMPLEX, "EXTEND COMPLEX: " << complexSelector)
@@ -1851,7 +1851,7 @@ namespace Sass {
18511851
*/
18521852
// We get a selector list with has something to extend and a subset_map with
18531853
// all extenders. Pick the ones that match our selectors in the list.
1854-
Selector_List_Ptr Extend::extendSelectorList(Selector_List_Obj pSelectorList, bool isReplace, bool& extendedSomething, std::set<Compound_Selector>& seen) {
1854+
Selector_List_Ptr Extend::extendSelectorList(Selector_List_Obj pSelectorList, bool isReplace, bool& extendedSomething, CompoundSelectorSet& seen) {
18551855

18561856
Selector_List_Obj pNewSelectors = SASS_MEMORY_NEW(Selector_List, pSelectorList->pstate(), pSelectorList->length());
18571857

@@ -1902,9 +1902,9 @@ namespace Sass {
19021902
// process tails
19031903
while (cur) {
19041904
// process header
1905-
if (cur->head() && seen.find(*cur->head()) == seen.end()) {
1906-
std::set<Compound_Selector> recseen(seen);
1907-
recseen.insert(*cur->head());
1905+
if (cur->head() && seen.find(cur->head()) == seen.end()) {
1906+
CompoundSelectorSet recseen(seen);
1907+
recseen.insert(cur->head());
19081908
// create a copy since we add multiple items if stuff get unwrapped
19091909
Compound_Selector_Obj cpy_head = SASS_MEMORY_NEW(Compound_Selector, cur->pstate());
19101910
for (Simple_Selector_Obj hs : *cur->head()) {
@@ -2016,7 +2016,7 @@ namespace Sass {
20162016

20172017
bool extendedSomething = false;
20182018

2019-
std::set<Compound_Selector> seen;
2019+
CompoundSelectorSet seen;
20202020
Selector_List_Obj pNewSelectorList = extendSelectorList(pObject->selector(), false, extendedSomething, seen);
20212021

20222022
if (extendedSomething && pNewSelectorList) {

src/extend.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ namespace Sass {
2323
private:
2424

2525
void extendObjectWithSelectorAndBlock(Ruleset_Ptr pObject);
26-
Node extendComplexSelector(Complex_Selector_Ptr sel, std::set<Compound_Selector>& seen, bool isReplace, bool isOriginal);
27-
Node extendCompoundSelector(Compound_Selector_Ptr sel, std::set<Compound_Selector>& seen, bool isReplace);
28-
bool complexSelectorHasExtension(Complex_Selector_Ptr selector, std::set<Compound_Selector>& seen);
26+
Node extendComplexSelector(Complex_Selector_Ptr sel, CompoundSelectorSet& seen, bool isReplace, bool isOriginal);
27+
Node extendCompoundSelector(Compound_Selector_Ptr sel, CompoundSelectorSet& seen, bool isReplace);
28+
bool complexSelectorHasExtension(Complex_Selector_Ptr selector, CompoundSelectorSet& seen);
2929
Node trim(Node& seqses, bool isReplace);
3030
Node weave(Node& path);
3131

3232
public:
33-
Selector_List_Ptr extendSelectorList(Selector_List_Obj pSelectorList, bool isReplace, bool& extendedSomething, std::set<Compound_Selector>& seen);
33+
Selector_List_Ptr extendSelectorList(Selector_List_Obj pSelectorList, bool isReplace, bool& extendedSomething, CompoundSelectorSet& seen);
3434
Selector_List_Ptr extendSelectorList(Selector_List_Obj pSelectorList, bool isReplace = false) {
3535
bool extendedSomething = false;
36-
std::set<Compound_Selector> seen;
36+
CompoundSelectorSet seen;
3737
return extendSelectorList(pSelectorList, isReplace, extendedSomething, seen);
3838
}
39-
Selector_List_Ptr extendSelectorList(Selector_List_Obj pSelectorList, std::set<Compound_Selector>& seen) {
39+
Selector_List_Ptr extendSelectorList(Selector_List_Obj pSelectorList, CompoundSelectorSet& seen) {
4040
bool isReplace = false;
4141
bool extendedSomething = false;
4242
return extendSelectorList(pSelectorList, isReplace, extendedSomething, seen);

0 commit comments

Comments
 (0)