Skip to content

Commit 1531857

Browse files
committed
Small cleanup
1 parent 8ffe8bc commit 1531857

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

include/gfx/timsort.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ namespace gfx {
9797
* Same as std::stable_sort(first, last).
9898
*/
9999
template <typename RandomAccessIterator>
100-
inline void timsort(RandomAccessIterator const first, RandomAccessIterator const last);
100+
void timsort(RandomAccessIterator const first, RandomAccessIterator const last);
101101

102102
/**
103-
* Same as std::stable_sort(first, last, c).
103+
* Same as std::stable_sort(first, last, compare).
104104
*/
105105
template <typename RandomAccessIterator, typename Compare>
106-
inline void timsort(RandomAccessIterator const first, RandomAccessIterator const last, Compare compare);
106+
void timsort(RandomAccessIterator const first, RandomAccessIterator const last, Compare compare);
107107

108108
// ---------------------------------------
109109
// Implementation
@@ -172,7 +172,7 @@ template <typename RandomAccessIterator, typename Compare> class TimSort {
172172

173173
GFX_TIMSORT_LOG("size: " << (hi - lo) << " tmp_.size(): " << ts.tmp_.size()
174174
<< " pending_.size(): " << ts.pending_.size());
175-
} // sort()
175+
}
176176

177177
static void binarySort(iter_t const lo, iter_t const hi, iter_t start, Compare compare) {
178178
GFX_TIMSORT_ASSERT(lo <= start && start <= hi);
@@ -181,7 +181,7 @@ template <typename RandomAccessIterator, typename Compare> class TimSort {
181181
}
182182
for (; start < hi; ++start) {
183183
GFX_TIMSORT_ASSERT(lo <= start);
184-
/*const*/ value_t pivot = GFX_TIMSORT_MOVE(*start);
184+
value_t pivot = GFX_TIMSORT_MOVE(*start);
185185

186186
iter_t const pos = std::upper_bound(lo, start, pivot, compare);
187187
for (iter_t p = start; p > pos; --p) {
@@ -199,12 +199,12 @@ template <typename RandomAccessIterator, typename Compare> class TimSort {
199199
return 1;
200200
}
201201

202-
if (compare(*(runHi++), *lo)) { // descending
202+
if (compare(*(runHi++), *lo)) { // decreasing
203203
while (runHi < hi && compare(*runHi, *(runHi - 1))) {
204204
++runHi;
205205
}
206206
std::reverse(lo, runHi);
207-
} else { // ascending
207+
} else { // non-decreasing
208208
while (runHi < hi && !compare(*runHi, *(runHi - 1))) {
209209
++runHi;
210210
}
@@ -627,19 +627,18 @@ template <typename RandomAccessIterator, typename Compare> class TimSort {
627627
GFX_TIMSORT_MOVE_RANGE(begin, begin + len, std::back_inserter(tmp_));
628628
}
629629

630-
// the only interface is the friend timsort() function
631630
template <typename IterT, typename LessT>
632631
friend void timsort(IterT first, IterT last, LessT c);
633632
};
634633

635634
template <typename RandomAccessIterator>
636-
inline void timsort(RandomAccessIterator const first, RandomAccessIterator const last) {
635+
void timsort(RandomAccessIterator const first, RandomAccessIterator const last) {
637636
typedef typename std::iterator_traits<RandomAccessIterator>::value_type value_type;
638637
timsort(first, last, std::less<value_type>());
639638
}
640639

641640
template <typename RandomAccessIterator, typename Compare>
642-
inline void timsort(RandomAccessIterator const first, RandomAccessIterator const last, Compare compare) {
641+
void timsort(RandomAccessIterator const first, RandomAccessIterator const last, Compare compare) {
643642
TimSort<RandomAccessIterator, Compare>::sort(first, last, compare);
644643
}
645644

0 commit comments

Comments
 (0)