Skip to content

Commit da6d5fa

Browse files
authored
Add missing LIBC_INLINE to qsort_pivot.h (#126249)
Fixes #111495
1 parent bcb0c3a commit da6d5fa

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libc/src/stdlib/qsort_pivot.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_STDLIB_QSORT_PIVOT_H
1010
#define LLVM_LIBC_SRC_STDLIB_QSORT_PIVOT_H
1111

12-
#include <stddef.h> // For size_t
12+
#include <stddef.h> // For size_t
1313

1414
namespace LIBC_NAMESPACE_DECL {
1515
namespace internal {
@@ -22,7 +22,7 @@ constexpr size_t PSEUDO_MEDIAN_REC_THRESHOLD = 64;
2222
// This chooses a pivot by sampling an adaptive amount of points, approximating
2323
// the quality of a median of sqrt(n) elements.
2424
template <typename A, typename F>
25-
size_t choose_pivot(const A &array, const F &is_less) {
25+
LIBC_INLINE size_t choose_pivot(const A &array, const F &is_less) {
2626
const size_t len = array.len();
2727

2828
if (len < 8) {
@@ -47,8 +47,8 @@ size_t choose_pivot(const A &array, const F &is_less) {
4747
// recursion depth and overall sample from f(n) = 3*f(n/8) -> f(n) =
4848
// O(n^(log(3)/log(8))) ~= O(n^0.528) elements.
4949
template <typename A, typename F>
50-
size_t median3_rec(const A &array, size_t a, size_t b, size_t c, size_t n,
51-
const F &is_less) {
50+
LIBC_INLINE size_t median3_rec(const A &array, size_t a, size_t b, size_t c,
51+
size_t n, const F &is_less) {
5252
if (n * 8 >= PSEUDO_MEDIAN_REC_THRESHOLD) {
5353
const size_t n8 = n / 8;
5454
a = median3_rec(array, a, a + (n8 * 4), a + (n8 * 7), n8, is_less);
@@ -60,7 +60,8 @@ size_t median3_rec(const A &array, size_t a, size_t b, size_t c, size_t n,
6060

6161
/// Calculates the median of 3 elements.
6262
template <typename A, typename F>
63-
size_t median3(const A &array, size_t a, size_t b, size_t c, const F &is_less) {
63+
LIBC_INLINE size_t median3(const A &array, size_t a, size_t b, size_t c,
64+
const F &is_less) {
6465
const void *a_ptr = array.get(a);
6566
const void *b_ptr = array.get(b);
6667
const void *c_ptr = array.get(c);

0 commit comments

Comments
 (0)