1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 05:25:08 +00:00
serenity/Userland/Libraries/LibJS/Heap/MarkedVector.cpp
Andreas Kling 8bb9fe63b7 LibJS: Add MarkedVector<T>
This abstracts a vector of Cell* with a strongly typed span() accessor
that gives you Span<T*> instead of Span<Cell*>.

It is intended to replace MarkedValueList in situations where you only
need to store pointers to Cell (or an even more specific type of Cell).

The API can definitely be improved, it's just the bare basics for now.
2021-12-16 22:48:17 +01:00

30 lines
584 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/Heap.h>
#include <LibJS/Heap/MarkedVector.h>
namespace JS {
MarkedVectorBase::MarkedVectorBase(Heap& heap)
: m_heap(heap)
{
m_heap.did_create_marked_vector({}, *this);
}
MarkedVectorBase::MarkedVectorBase(MarkedVectorBase&& other)
: m_heap(other.m_heap)
, m_cells(move(other.m_cells))
{
m_heap.did_create_marked_vector({}, *this);
}
MarkedVectorBase::~MarkedVectorBase()
{
m_heap.did_destroy_marked_vector({}, *this);
}
}