Skip to content

Commit 8477851

Browse files
committed
fix: optimize match iteration logic in Expression class
1 parent b01cc99 commit 8477851

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cucumber_cpp/library/cucumber_expression/Expression.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ namespace cucumber_cpp::library::cucumber_expression
4444
return std::nullopt;
4545

4646
std::vector<std::any> result;
47+
result.reserve(converters.size());
4748

4849
auto converterIter = converters.begin();
49-
auto matchIt = smatch.begin() + 1;
50+
auto matchIter = smatch.begin() + 1;
5051

51-
while (matchIt != smatch.end() && converterIter != converters.end())
52+
while (matchIter != smatch.end() && converterIter != converters.end())
5253
{
53-
result.emplace_back(converterIter->converter({ matchIt, matchIt + converterIter->matches }));
54+
result.emplace_back(converterIter->converter({ matchIter, matchIter + converterIter->matches }));
5455

55-
matchIt = std::next(matchIt, converterIter->matches);
56+
matchIter = std::next(matchIter, converterIter->matches);
5657
converterIter = std::next(converterIter);
5758
}
5859

0 commit comments

Comments
 (0)