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

Daniel Thornburgh via libc-commits libc-commits at lists.llvm.org
Thu Nov 14 11:57:57 PST 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 {
----------------
mysterymath wrote:

>From the above, I like `EmbeddedHeapAlloc`; either should fit the intended use case well. But if it's alright, I think I'd like to do a NFC reorganization PR afterwards; this is already a pretty enormous change.

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


More information about the libc-commits mailing list