From 430ca81bfdb7b1430d29def8d05751065a947143 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 29 May 2016 02:41:58 +0100 Subject: [PATCH] pass compare func by reference in sort impl (don't copy it around) --- ostd/algorithm.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ostd/algorithm.hh b/ostd/algorithm.hh index 180c56e..2f062c1 100644 --- a/ostd/algorithm.hh +++ b/ostd/algorithm.hh @@ -55,7 +55,7 @@ inline auto is_partitioned(F &&func) { namespace detail { template - static void insort(R range, C compare) { + static void insort(R range, C &compare) { RangeSize rlen = range.size(); for (RangeSize i = 1; i < rlen; ++i) { RangeSize j = i; @@ -70,7 +70,7 @@ namespace detail { template static void hs_sift_down(R range, RangeSize s, - RangeSize e, C compare) { + RangeSize e, C &compare) { RangeSize r = s; while ((r * 2 + 1) <= e) { RangeSize ch = r * 2 + 1; @@ -87,7 +87,7 @@ namespace detail { } template - static void heapsort(R range, C compare) { + static void heapsort(R range, C &compare) { RangeSize len = range.size(); RangeSize st = (len - 2) / 2; for (;;) { @@ -103,7 +103,7 @@ namespace detail { } template - static void introloop(R range, C compare, RangeSize depth) { + static void introloop(R range, C &compare, RangeSize depth) { if (range.size() <= 10) { detail::insort(range, compare); return; @@ -127,7 +127,7 @@ namespace detail { } template - inline void introsort(R range, C compare) { + inline void introsort(R range, C &compare) { detail::introloop(range, compare, RangeSize(2 * (log(range.size()) / log(2)))); }