[libcxx-commits] [libcxx] [libc++] Refactor some code in monotonic_buffer_resource (PR #117271)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 23 03:38:32 PST 2024
================
@@ -429,23 +429,18 @@ static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {
return ptr;
}
-void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) {
- if (!__cur_)
- return nullptr;
- void* new_ptr = static_cast<void*>(__cur_);
- size_t new_capacity = (__cur_ - __start_);
- void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);
- if (aligned_ptr != nullptr)
- __cur_ = static_cast<char*>(new_ptr);
- return aligned_ptr;
-}
-
-void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) {
- void* new_ptr = static_cast<void*>(__cur_);
- size_t new_capacity = (__cur_ - __start_);
+template <typename Chunk, bool is_initial = false>
----------------
frederick-vs-ja wrote:
I think the explicitly specified template parameter should appear first.
```suggestion
template <bool is_initial, typename Chunk>
```
The usages below should be modified correspondingly.
https://github.com/llvm/llvm-project/pull/117271
More information about the libcxx-commits
mailing list