1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-22 07:42:37 +00:00

perf: avoid std::advance in cache.cc (#7025)

This commit is contained in:
Yat Ho 2024-08-13 08:03:02 +08:00 committed by GitHub
parent fe385259cc
commit 35ef8cf7a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,16 +48,15 @@ std::pair<Cache::CIter, Cache::CIter> Cache::find_biggest_span(CIter const begin
for (auto span_begin = begin; span_begin < end;) for (auto span_begin = begin; span_begin < end;)
{ {
auto span_end = find_span_end(span_begin, end); auto span_end = find_span_end(span_begin, end);
auto const len = std::distance(span_begin, span_end);
if (len > biggest_len) if (auto const len = std::distance(span_begin, span_end); len > biggest_len)
{ {
biggest_begin = span_begin; biggest_begin = span_begin;
biggest_end = span_end; biggest_end = span_end;
biggest_len = len; biggest_len = len;
} }
std::advance(span_begin, len); span_begin = span_end;
} }
return { biggest_begin, biggest_end }; return { biggest_begin, biggest_end };