Skip to content

Commit 3d438f1

Browse files
committed
Commit unrolled range-based for loops
1 parent 61dc1c4 commit 3d438f1

22 files changed

+109
-115
lines changed

src/ast.cpp

+18-20
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Sass {
3232
bool Selector_List::find ( bool (*f)(AST_Node_Obj) )
3333
{
3434
// check children first
35-
for (Complex_Selector_Obj sel : elements()) {
35+
for (auto __sel = (elements()).begin(); __sel != (elements()).end(); ++__sel) { Complex_Selector_Obj sel = *(__sel);
3636
if (sel->find(f)) return true;
3737
}
3838
// execute last
@@ -42,7 +42,7 @@ namespace Sass {
4242
bool Compound_Selector::find ( bool (*f)(AST_Node_Obj) )
4343
{
4444
// check children first
45-
for (Simple_Selector_Obj sel : elements()) {
45+
for (auto __sel = (elements()).begin(); __sel != (elements()).end(); ++__sel) { Simple_Selector_Obj sel = *(__sel);
4646
if (sel->find(f)) return true;
4747
}
4848
// execute last
@@ -95,7 +95,7 @@ namespace Sass {
9595

9696
void Arguments::set_delayed(bool delayed)
9797
{
98-
for (Argument_Obj arg : elements()) {
98+
for (auto __arg = (elements()).begin(); __arg != (elements()).end(); ++__arg) { Argument_Obj arg = *(__arg);
9999
if (arg) arg->set_delayed(delayed);
100100
}
101101
is_delayed(delayed);
@@ -168,15 +168,15 @@ namespace Sass {
168168

169169
bool Compound_Selector::has_parent_ref() const
170170
{
171-
for (Simple_Selector_Obj s : elements()) {
171+
for (auto __s = (elements()).begin(); __s != (elements()).end(); ++__s) { Simple_Selector_Obj s = *(__s);
172172
if (s && s->has_parent_ref()) return true;
173173
}
174174
return false;
175175
}
176176

177177
bool Compound_Selector::has_real_parent_ref() const
178178
{
179-
for (Simple_Selector_Obj s : elements()) {
179+
for (auto __s = (elements()).begin(); __s != (elements()).end(); ++__s) { Simple_Selector_Obj s = *(__s);
180180
if (s && s->has_real_parent_ref()) return true;
181181
}
182182
return false;
@@ -843,7 +843,7 @@ namespace Sass {
843843

844844
bool Compound_Selector::is_superselector_of(Selector_List_Obj rhs, std::string wrapped)
845845
{
846-
for (Complex_Selector_Obj item : rhs->elements()) {
846+
for (auto __item = (rhs->elements()).begin(); __item != (rhs->elements()).end(); ++__item) { Complex_Selector_Obj item = *(__item);
847847
if (is_superselector_of(item, wrapped)) return true;
848848
}
849849
return false;
@@ -960,8 +960,8 @@ namespace Sass {
960960
rset.insert(r->to_string());
961961
}
962962

963-
//for (auto l : lset) { cerr << "l: " << l << endl; }
964-
//for (auto r : rset) { cerr << "r: " << r << endl; }
963+
//for (auto __l = (lset).begin(); __l != (lset).end(); ++__l) { auto l = *(__l); cerr << "l: " << l << endl; }
964+
//for (auto __r = (rset).begin(); __r != (rset).end(); ++__r) { auto r = *(__r); cerr << "r: " << r << endl; }
965965

966966
if (lset.empty()) return true;
967967
// return true if rset contains all the elements of lset
@@ -1403,7 +1403,7 @@ namespace Sass {
14031403
retval = this->tails(tails);
14041404
}
14051405

1406-
for (Simple_Selector_Obj ss : head->elements()) {
1406+
for (auto __ss = (head->elements()).begin(); __ss != (head->elements()).end(); ++__ss) { Simple_Selector_Obj ss = *(__ss);
14071407
if (Wrapped_Selector_Ptr ws = Cast<Wrapped_Selector>(ss)) {
14081408
if (Selector_List_Ptr sl = Cast<Selector_List>(ws->selector())) {
14091409
if (parents) ws->selector(sl->resolve_parent_refs(pstack, implicit_parent));
@@ -1563,15 +1563,15 @@ namespace Sass {
15631563

15641564
bool Selector_List::has_parent_ref() const
15651565
{
1566-
for (Complex_Selector_Obj s : elements()) {
1566+
for (auto __s = (elements()).begin(); __s != (elements()).end(); ++__s) { Complex_Selector_Obj s = *(__s);
15671567
if (s && s->has_parent_ref()) return true;
15681568
}
15691569
return false;
15701570
}
15711571

15721572
bool Selector_List::has_real_parent_ref() const
15731573
{
1574-
for (Complex_Selector_Obj s : elements()) {
1574+
for (auto __s = (elements()).begin(); __s != (elements()).end(); ++__s) { Complex_Selector_Obj s = *(__s);
15751575
if (s && s->has_real_parent_ref()) return true;
15761576
}
15771577
return false;
@@ -1672,7 +1672,7 @@ namespace Sass {
16721672
{
16731673

16741674
Selector_List_Ptr extender = this;
1675-
for (auto complex_sel : extendee->elements()) {
1675+
for (auto __complex_sel = (extendee->elements()).begin(); __complex_sel != (extendee->elements()).end(); ++__complex_sel) { auto complex_sel = *(__complex_sel);
16761676
Complex_Selector_Obj c = complex_sel;
16771677

16781678

@@ -1741,7 +1741,7 @@ namespace Sass {
17411741
Argument_Obj Arguments::get_rest_argument()
17421742
{
17431743
if (this->has_rest_argument()) {
1744-
for (Argument_Obj arg : this->elements()) {
1744+
for (auto __arg = (this->elements()).begin(); __arg != (this->elements()).end(); ++__arg) { Argument_Obj arg = *(__arg);
17451745
if (arg->is_rest_argument()) {
17461746
return arg;
17471747
}
@@ -1753,7 +1753,7 @@ namespace Sass {
17531753
Argument_Obj Arguments::get_keyword_argument()
17541754
{
17551755
if (this->has_keyword_argument()) {
1756-
for (Argument_Obj arg : this->elements()) {
1756+
for (auto __arg = (this->elements()).begin(); __arg != (this->elements()).end(); ++__arg) { Argument_Obj arg = *(__arg);
17571757
if (arg->is_keyword_argument()) {
17581758
return arg;
17591759
}
@@ -1924,8 +1924,7 @@ namespace Sass {
19241924
denominator_units_.clear();
19251925

19261926
// build them by iterating over the exponents
1927-
for (auto exp : exponents)
1928-
{
1927+
for (auto __exp = (exponents).begin(); __exp != (exponents).end(); ++__exp) { auto exp = *(__exp);
19291928
// maybe there is more effecient way to push
19301929
// the same item multiple times to a vector?
19311930
for(size_t i = 0, S = abs(exp.second); i < S; ++i)
@@ -2136,8 +2135,7 @@ namespace Sass {
21362135
denominator_units_.clear();
21372136

21382137
// build them by iterating over the exponents
2139-
for (auto exp : exponents)
2140-
{
2138+
for (auto __exp = (exponents).begin(); __exp != (exponents).end(); ++__exp) { auto exp = *(__exp);
21412139
// maybe there is more effecient way to push
21422140
// the same item multiple times to a vector?
21432141
for(size_t i = 0, S = abs(exp.second); i < S; ++i)
@@ -2312,7 +2310,7 @@ namespace Sass {
23122310
{
23132311
if (Map_Ptr_Const r = Cast<Map>(&rhs)) {
23142312
if (length() != r->length()) return false;
2315-
for (auto key : keys()) {
2313+
for (auto __key = (keys()).begin(); __key != (keys()).end(); ++__key) { auto key = *(__key);
23162314
Expression_Obj lv = at(key);
23172315
Expression_Obj rv = r->at(key);
23182316
if (!rv || !lv) return false;
@@ -2405,7 +2403,7 @@ namespace Sass {
24052403
List_Obj Map::to_list(ParserState& pstate) {
24062404
List_Obj ret = SASS_MEMORY_NEW(List, pstate, length(), SASS_COMMA);
24072405

2408-
for (auto key : keys()) {
2406+
for (auto __key = (keys()).begin(); __key != (keys()).end(); ++__key) { auto key = *(__key);
24092407
List_Obj l = SASS_MEMORY_NEW(List, pstate, 2);
24102408
l->append(key);
24112409
l->append(at(key));

src/ast.hpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ namespace Sass {
329329
virtual size_t hash()
330330
{
331331
if (hash_ == 0) {
332-
for (T& el : elements_) {
332+
for (auto __el = (elements_).begin(); __el != (elements_).end(); ++__el) { T& el = *(__el);
333333
hash_combine(hash_, el->hash());
334334
}
335335
}
@@ -395,7 +395,7 @@ namespace Sass {
395395
return *this;
396396
}
397397

398-
for (auto key : h->keys()) {
398+
for (auto __key = (h->keys()).begin(); __key != (h->keys()).end(); ++__key) { auto key = *(__key);
399399
*this << std::make_pair(key, h->at(key));
400400
}
401401

@@ -1137,7 +1137,7 @@ namespace Sass {
11371137
virtual size_t hash()
11381138
{
11391139
if (hash_ == 0) {
1140-
for (auto key : keys()) {
1140+
for (auto __key = (keys()).begin(); __key != (keys()).end(); ++__key) { auto key = *(__key);
11411141
hash_combine(hash_, key->hash());
11421142
hash_combine(hash_, at(key)->hash());
11431143
}
@@ -1477,8 +1477,7 @@ namespace Sass {
14771477
{
14781478
if (hash_ == 0) {
14791479
hash_ = std::hash<std::string>()(name());
1480-
for (auto argument : arguments()->elements())
1481-
{ hash_combine(hash_, argument->hash()); }
1480+
for (auto __argument = (arguments()->elements()).begin(); __argument != (arguments()->elements()).end(); ++__argument) { auto argument = *(__argument); hash_combine(hash_, argument->hash()); }
14821481
}
14831482
return hash_;
14841483
}
@@ -1582,10 +1581,8 @@ namespace Sass {
15821581
{
15831582
if (hash_ == 0) {
15841583
hash_ = std::hash<double>()(value_);
1585-
for (const auto numerator : numerator_units())
1586-
{ hash_combine(hash_, std::hash<std::string>()(numerator)); }
1587-
for (const auto denominator : denominator_units())
1588-
{ hash_combine(hash_, std::hash<std::string>()(denominator)); }
1584+
for (auto __numerator = (numerator_units()).begin(); __numerator != (numerator_units()).end(); ++__numerator) { const auto numerator = *(__numerator); hash_combine(hash_, std::hash<std::string>()(numerator)); }
1585+
for (auto __denominator = (denominator_units()).begin(); __denominator != (denominator_units()).end(); ++__denominator) { const auto denominator = *(__denominator); hash_combine(hash_, std::hash<std::string>()(denominator)); }
15891586
}
15901587
return hash_;
15911588
}
@@ -1757,7 +1754,7 @@ namespace Sass {
17571754
bool is_right_interpolant(void) const;
17581755
// void has_interpolants(bool tc) { }
17591756
bool has_interpolants() {
1760-
for (auto el : elements()) {
1757+
for (auto __el = (elements()).begin(); __el != (elements()).end(); ++__el) { auto el = *(__el);
17611758
if (el->is_interpolant()) return true;
17621759
}
17631760
return false;
@@ -1767,8 +1764,7 @@ namespace Sass {
17671764
virtual size_t hash()
17681765
{
17691766
if (hash_ == 0) {
1770-
for (auto string : elements())
1771-
{ hash_combine(hash_, string->hash()); }
1767+
for (auto __string = (elements()).begin(); __string != (elements()).end(); ++__string) { auto string = *(__string); hash_combine(hash_, string->hash()); }
17721768
}
17731769
return hash_;
17741770
}
@@ -2978,12 +2974,12 @@ namespace Sass {
29782974
}
29792975
virtual void set_media_block(Media_Block_Ptr mb) {
29802976
media_block(mb);
2981-
for (Complex_Selector_Obj cs : elements()) {
2977+
for (auto __cs = (elements()).begin(); __cs != (elements()).end(); ++__cs) { Complex_Selector_Obj cs = *(__cs);
29822978
cs->set_media_block(mb);
29832979
}
29842980
}
29852981
virtual bool has_placeholder() {
2986-
for (Complex_Selector_Obj cs : elements()) {
2982+
for (auto __cs = (elements()).begin(); __cs != (elements()).end(); ++__cs) { Complex_Selector_Obj cs = *(__cs);
29872983
if (cs->has_placeholder()) return true;
29882984
}
29892985
return false;

src/bind.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace Sass {
7171
rest->separator(),
7272
true);
7373
// wrap each item from list as an argument
74-
for (Expression_Obj item : rest->elements()) {
74+
for (auto __item = (rest->elements()).begin(); __item != (rest->elements()).end(); ++__item) { Expression_Obj item = *(__item);
7575
if (Argument_Obj arg = Cast<Argument>(item)) {
7676
arglist->append(SASS_MEMORY_COPY(arg)); // copy
7777
} else {
@@ -96,7 +96,7 @@ namespace Sass {
9696
List_Ptr arglist = SASS_MEMORY_NEW(List, p->pstate(), 0, SASS_COMMA, true);
9797
env->local_frame()[p->name()] = arglist;
9898
Map_Obj argmap = Cast<Map>(a->value());
99-
for (auto key : argmap->keys()) {
99+
for (auto __key = (argmap->keys()).begin(); __key != (argmap->keys()).end(); ++__key) { auto key = *(__key);
100100
if (String_Constant_Obj str = Cast<String_Constant>(key)) {
101101
std::string param = unquote(str->value());
102102
arglist->append(SASS_MEMORY_NEW(Argument,
@@ -217,7 +217,7 @@ namespace Sass {
217217
} else if (a->is_keyword_argument()) {
218218
Map_Obj argmap = Cast<Map>(a->value());
219219

220-
for (auto key : argmap->keys()) {
220+
for (auto __key = (argmap->keys()).begin(); __key != (argmap->keys()).end(); ++__key) { auto key = *(__key);
221221
std::string param = "$" + unquote(Cast<String_Constant>(key)->value());
222222

223223
if (!param_map.count(param)) {

src/check_nesting.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace Sass {
6363
}
6464

6565
if (b) {
66-
for (auto n : b->elements()) {
66+
for (auto __n = (b->elements()).begin(); __n != (b->elements()).end(); ++__n) { auto n = *(__n);
6767
n->perform(this);
6868
}
6969
}
@@ -179,7 +179,7 @@ namespace Sass {
179179

180180
// void CheckNesting::invalid_import_parent(Statement_Ptr parent)
181181
// {
182-
// for (auto pp : this->parents) {
182+
// for (auto __pp = (this->parents).begin(); __pp != (this->parents).end(); ++__pp) { auto pp = *(__pp);
183183
// if (
184184
// Cast<Each>(pp) ||
185185
// Cast<For>(pp) ||
@@ -210,7 +210,7 @@ namespace Sass {
210210

211211
void CheckNesting::invalid_mixin_definition_parent(Statement_Ptr parent)
212212
{
213-
for (Statement_Ptr pp : this->parents) {
213+
for (auto __pp = (this->parents).begin(); __pp != (this->parents).end(); ++__pp) { Statement_Ptr pp = *(__pp);
214214
if (
215215
Cast<Each>(pp) ||
216216
Cast<For>(pp) ||
@@ -230,7 +230,7 @@ namespace Sass {
230230

231231
void CheckNesting::invalid_function_parent(Statement_Ptr parent)
232232
{
233-
for (Statement_Ptr pp : this->parents) {
233+
for (auto __pp = (this->parents).begin(); __pp != (this->parents).end(); ++__pp) { Statement_Ptr pp = *(__pp);
234234
if (
235235
Cast<Each>(pp) ||
236236
Cast<For>(pp) ||

src/context.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ namespace Sass {
101101
collect_plugin_paths(c_options.plugin_paths);
102102

103103
// load plugins and register custom behaviors
104-
for(auto plug : plugin_paths) { plugins.load_plugins(plug); }
105-
for(auto fn : plugins.get_headers()) { c_headers.push_back(fn); }
106-
for(auto fn : plugins.get_importers()) { c_importers.push_back(fn); }
107-
for(auto fn : plugins.get_functions()) { c_functions.push_back(fn); }
104+
for (auto __plug = (plugin_paths).begin(); __plug != (plugin_paths).end(); ++__plug) { auto plug = *(__plug); plugins.load_plugins(plug); }
105+
for (auto __fn = (plugins.get_headers()).begin(); __fn != (plugins.get_headers()).end(); ++__fn) { auto fn = *(__fn); c_headers.push_back(fn); }
106+
for (auto __fn = (plugins.get_importers()).begin(); __fn != (plugins.get_importers()).end(); ++__fn) { auto fn = *(__fn); c_importers.push_back(fn); }
107+
for (auto __fn = (plugins.get_functions()).begin(); __fn != (plugins.get_functions()).end(); ++__fn) { auto fn = *(__fn); c_functions.push_back(fn); }
108108

109109
// sort the items by priority (lowest first)
110110
sort (c_headers.begin(), c_headers.end(), sort_importers);
@@ -419,7 +419,7 @@ namespace Sass {
419419
// need one correct import
420420
bool has_import = false;
421421
// process all custom importers (or custom headers)
422-
for (Sass_Importer_Entry& importer_ent : importers) {
422+
for (auto __importer_ent = (importers).begin(); __importer_ent != (importers).end(); ++__importer_ent) { Sass_Importer_Entry& importer_ent = *(__importer_ent);
423423
// int priority = sass_importer_get_priority(importer);
424424
Sass_Importer_Fn fn = sass_importer_get_function(importer_ent);
425425
// skip importer if it returns NULL

0 commit comments

Comments
 (0)