LibGC: Prefer Optional<StringView> for CellAllocator class name
In an effort towards removing the use of the null state of StringView.
This commit is contained in:
parent
1787f06bbd
commit
95e13f71a9
3 changed files with 7 additions and 7 deletions
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace GC {
|
||||
|
||||
CellAllocator::CellAllocator(size_t cell_size, StringView class_name, bool overrides_must_survive_garbage_collection, bool overrides_finalize)
|
||||
CellAllocator::CellAllocator(size_t cell_size, Optional<StringView> class_name, bool overrides_must_survive_garbage_collection, bool overrides_finalize)
|
||||
: m_class_name(class_name)
|
||||
, m_cell_size(cell_size)
|
||||
, m_overrides_must_survive_garbage_collection(overrides_must_survive_garbage_collection)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ namespace GC {
|
|||
|
||||
class GC_API CellAllocator {
|
||||
public:
|
||||
CellAllocator(size_t cell_size, StringView = {}, bool overrides_must_survive_garbage_collection = false, bool overrides_finalize = false);
|
||||
CellAllocator(size_t cell_size, Optional<StringView> = {}, bool overrides_must_survive_garbage_collection = false, bool overrides_finalize = false);
|
||||
~CellAllocator() = default;
|
||||
|
||||
StringView class_name() const { return m_class_name; }
|
||||
Optional<StringView> class_name() const { return m_class_name; }
|
||||
size_t cell_size() const { return m_cell_size; }
|
||||
|
||||
Cell* allocate_cell(Heap&);
|
||||
|
|
@ -65,7 +65,7 @@ public:
|
|||
FlatPtr max_block_address() const { return m_max_block_address; }
|
||||
|
||||
private:
|
||||
StringView m_class_name;
|
||||
Optional<StringView> m_class_name;
|
||||
size_t const m_cell_size;
|
||||
|
||||
BlockAllocator m_block_allocator;
|
||||
|
|
|
|||
|
|
@ -342,10 +342,10 @@ void Heap::dump_allocators()
|
|||
total_in_committed_blocks += blocks.size() * HeapBlock::BLOCK_SIZE;
|
||||
|
||||
StringBuilder builder;
|
||||
if (allocator.class_name().is_null())
|
||||
builder.appendff("generic ({}b)", allocator.cell_size());
|
||||
if (allocator.class_name().has_value())
|
||||
builder.appendff("{} ({}b)", allocator.class_name().value(), allocator.cell_size());
|
||||
else
|
||||
builder.appendff("{} ({}b)", allocator.class_name(), allocator.cell_size());
|
||||
builder.appendff("generic ({}b)", allocator.cell_size());
|
||||
|
||||
builder.appendff(" x {}", total_live_cells);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue