Skip to content

Commit

Permalink
Improve happy_eyeballs_detection performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Oct 23, 2023
1 parent 09e2ba6 commit c3fc4c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions proxy/include/proxy/async_connect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,15 @@ namespace asio_util {
{
bool has_a = false, has_aaaa = false;

for (auto begin_ = begin; begin_ != end; begin_++)
for (; begin != end && !(has_a && has_aaaa); begin++)
{
const auto& addr = begin_->endpoint().address();
const auto& addr = begin->endpoint().address();

has_aaaa |= net::ip::address(addr).is_v6();
has_a |= net::ip::address(addr).is_v4();
if (!has_aaaa)
has_aaaa = addr.is_v6();

if (!has_a)
has_a = addr.is_v4();
}

if (has_aaaa && has_a)
Expand Down

0 comments on commit c3fc4c9

Please sign in to comment.