[libc-commits] [PATCH] D152467: [libc] Add qsort_r

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jun 9 16:18:32 PDT 2023


sivachandra accepted this revision.
sivachandra added inline comments.


================
Comment at: libc/src/stdlib/qsort_util.h:20
 
-class Array {
-  typedef int (*comparator)(const void *, const void *);
+// TODO: better names
+typedef int (*Compar)(const void *, const void *);
----------------
May be `Compare` and `CompareWithState`.


================
Comment at: libc/src/stdlib/qsort_util.h:21
+// TODO: better names
+typedef int (*Compar)(const void *, const void *);
+typedef int (*Compar_r)(const void *, const void *, void *);
----------------
Nit: Since you are touching this anyway, you can change it to:

```
using Compare = int(const void *, const void *);
using CompareWithState = int(const void *, const void *, void *);
```


================
Comment at: libc/src/stdlib/qsort_util.h:24
+
+enum CompType { comp, comp_r };
+
----------------
All caps. Also, if you make it an enum class, then you can get scoped names like `COMPARE` and `COMPARE_WITH_STATE`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152467/new/

https://reviews.llvm.org/D152467



More information about the libc-commits mailing list