-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing LIBC_INLINE to qsort_pivot.h #126249
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-libc Author: Lukas Bergdoll (Voultapher) ChangesFixes #111495 Full diff: https://github.com/llvm/llvm-project/pull/126249.diff 1 Files Affected:
diff --git a/libc/src/stdlib/qsort_pivot.h b/libc/src/stdlib/qsort_pivot.h
index b27e74663d901e9..f202ea4f43fa351 100644
--- a/libc/src/stdlib/qsort_pivot.h
+++ b/libc/src/stdlib/qsort_pivot.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_STDLIB_QSORT_PIVOT_H
#define LLVM_LIBC_SRC_STDLIB_QSORT_PIVOT_H
-#include <stddef.h> // For size_t
+#include <stddef.h> // For size_t
namespace LIBC_NAMESPACE_DECL {
namespace internal {
@@ -22,7 +22,7 @@ constexpr size_t PSEUDO_MEDIAN_REC_THRESHOLD = 64;
// This chooses a pivot by sampling an adaptive amount of points, approximating
// the quality of a median of sqrt(n) elements.
template <typename A, typename F>
-size_t choose_pivot(const A &array, const F &is_less) {
+LIBC_INLINE size_t choose_pivot(const A &array, const F &is_less) {
const size_t len = array.len();
if (len < 8) {
@@ -47,8 +47,8 @@ size_t choose_pivot(const A &array, const F &is_less) {
// recursion depth and overall sample from f(n) = 3*f(n/8) -> f(n) =
// O(n^(log(3)/log(8))) ~= O(n^0.528) elements.
template <typename A, typename F>
-size_t median3_rec(const A &array, size_t a, size_t b, size_t c, size_t n,
- const F &is_less) {
+LIBC_INLINE size_t median3_rec(const A &array, size_t a, size_t b, size_t c,
+ size_t n, const F &is_less) {
if (n * 8 >= PSEUDO_MEDIAN_REC_THRESHOLD) {
const size_t n8 = n / 8;
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,
/// Calculates the median of 3 elements.
template <typename A, typename F>
-size_t median3(const A &array, size_t a, size_t b, size_t c, const F &is_less) {
+LIBC_INLINE size_t median3(const A &array, size_t a, size_t b, size_t c,
+ const F &is_less) {
const void *a_ptr = array.get(a);
const void *b_ptr = array.get(b);
const void *c_ptr = array.get(c);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too, and I agree this completes #111495.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(er, actually press the LGTM button this time, ahem)
Fixes #111495