summaryrefslogtreecommitdiffstats
path: root/util/generic/algorithm.h
diff options
context:
space:
mode:
authorswarmer <[email protected]>2024-09-26 22:15:27 +0300
committerswarmer <[email protected]>2024-09-26 22:29:56 +0300
commit9598e6ce746a6ae937ccc291c9c5e64db14ce62e (patch)
tree62236ad1aadb33c8d677290c805267714623ac7e /util/generic/algorithm.h
parent8a41c7311c51ea81eaae2626bbe464956f2a8288 (diff)
Support move-only key types in the Max/MinElementBy routines
It is also slightly faster for non-trivial key types. commit_hash:4104cabfe8dc9a51174034c62aae25be16b57bf9
Diffstat (limited to 'util/generic/algorithm.h')
-rw-r--r--util/generic/algorithm.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index a770ab3033c..d1f48c479d9 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -21,11 +21,11 @@ namespace NPrivate {
auto bestValue = func(*begin);
auto bestPos = begin;
- for (auto i = ++begin; i != end; ++i) {
- auto curValue = func(*i);
+ for (++begin; begin != end; ++begin) {
+ auto curValue = func(*begin);
if (pred(curValue, bestValue)) {
- bestValue = curValue;
- bestPos = i;
+ bestValue = std::move(curValue);
+ bestPos = begin;
}
}