[libc-commits] [libc] [libc] Use best-fit binary trie to make malloc logarithmic (PR #106259)

via libc-commits libc-commits at lists.llvm.org
Thu Oct 10 10:41:14 PDT 2024


================
@@ -28,23 +28,16 @@ extern "C" cpp::byte __llvm_libc_heap_limit;
 using cpp::optional;
 using cpp::span;
 
-inline constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
+LIBC_INLINE constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
 
-static constexpr cpp::array<size_t, 6> DEFAULT_BUCKETS{16,  32,  64,
-                                                       128, 256, 512};
-
-template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
+class FreeListHeap {
----------------
nopsledder wrote:

nit: I can't help feeling like this isn't the most descriptive name for this type anymore. Same with FreeListHeapBuffer, as they're both just "the thing that holds the trie of lists".

https://github.com/llvm/llvm-project/pull/106259


More information about the libc-commits mailing list