Skip to content

Commit

Permalink
url: use foreach-style C++ loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Sep 27, 2018
1 parent 7dae872 commit bcad6b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ class URL {

std::string path() const {
std::string ret;
for (auto i = context_.path.begin(); i != context_.path.end(); i++) {
for (const auto& i : context_.path) {
ret += '/';
ret += *i;
ret += i;
}
return ret;
}
Expand Down

1 comment on commit bcad6b4

@refack
Copy link
Contributor

@refack refack commented on bcad6b4 Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't mean to be nosy, but I found this by chance.
The "common" name is ranged-based-for-loop or range-for
https://en.cppreference.com/w/cpp/language/range-for
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-for-range

You can use this cool toy (Compiler Explorer) https://godbolt.org/z/hBERPp

Please sign in to comment.