parser: Use ranged for loops where appropriate

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-03-16 09:38:53 +01:00
parent aa233bd5f9
commit 33012e1513

View File

@ -956,8 +956,8 @@ namespace stdex
virtual void invalidate() virtual void invalidate()
{ {
for (auto i = m_collection.begin(); i != m_collection.end(); ++i) for (auto& el: m_collection)
(*i)->invalidate(); el->invalidate();
basic_tester<T>::invalidate(); basic_tester<T>::invalidate();
} }
@ -1183,8 +1183,8 @@ namespace stdex
_In_ int flags = match_default) _In_ int flags = match_default)
{ {
assert(text || start >= end); assert(text || start >= end);
for (auto i = m_collection.begin(); i != m_collection.end(); ++i) for (auto& el: m_collection)
(*i)->invalidate(); el->invalidate();
if (match_recursively(text, start, end, flags)) { if (match_recursively(text, start, end, flags)) {
interval.start = start; interval.start = start;
return true; return true;
@ -1201,17 +1201,17 @@ namespace stdex
_In_ int flags = match_default) _In_ int flags = match_default)
{ {
bool all_matched = true; bool all_matched = true;
for (auto i = m_collection.begin(); i != m_collection.cend(); ++i) { for (auto& el: m_collection) {
if (!(*i)->interval) { if (!el->interval) {
// Element was not matched in permutatuion yet. // Element was not matched in permutatuion yet.
all_matched = false; all_matched = false;
if ((*i)->match(text, start, end, flags)) { if (el->match(text, start, end, flags)) {
// Element matched for the first time. // Element matched for the first time.
if (match_recursively(text, (*i)->interval.end, end, flags)) { if (match_recursively(text, el->interval.end, end, flags)) {
// Rest of the elements matched too. // Rest of the elements matched too.
return true; return true;
} }
(*i)->invalidate(); el->invalidate();
} }
} }
} }