[libc-commits] [libc] [libc] Refactor qsort code (PR #198781)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Wed May 20 06:52:35 PDT 2026
================
@@ -0,0 +1,150 @@
+
+//===-- A template class for testing reentrant qsort functions --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "test/UnitTest/Test.h"
+
+template <typename QsortFnTy, typename SizeTy>
+class QsortReentrantTest : public LIBC_NAMESPACE::testing::Test {
+private:
+ static int int_compare_count(const void *l, const void *r, void *count_arg) {
+ int li = *static_cast<const int *>(l);
+ int ri = *static_cast<const int *>(r);
+ SizeTy *count = static_cast<SizeTy *>(count_arg);
+ *count = *count + 1;
+ if (li == ri)
+ return 0;
+ else if (li > ri)
----------------
kaladron wrote:
```suggestion
if (li > ri)
```
The else is not needed after a return (here and below)
https://github.com/llvm/llvm-project/pull/198781
More information about the libc-commits
mailing list