mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibJS: Make MarkedValueList inherit from Vector<Value>
This makes the nicer vector API available to MVL without extra wrapper functions.
This commit is contained in:
parent
9a00699983
commit
8d9c5a8e70
Notes:
sideshowbarker
2024-07-19 02:50:41 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/8d9c5a8e70b Pull-request: https://github.com/SerenityOS/serenity/pull/3432 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg ✅
2 changed files with 10 additions and 15 deletions
|
@ -36,8 +36,8 @@ MarkedValueList::MarkedValueList(Heap& heap)
|
|||
}
|
||||
|
||||
MarkedValueList::MarkedValueList(MarkedValueList&& other)
|
||||
: m_heap(other.m_heap)
|
||||
, m_values(move(other.m_values))
|
||||
: AK::Vector<Value, 32>(move(static_cast<Vector<Value, 32>&>(other)))
|
||||
, m_heap(other.m_heap)
|
||||
{
|
||||
m_heap.did_create_marked_value_list({}, *this);
|
||||
}
|
||||
|
@ -47,9 +47,4 @@ MarkedValueList::~MarkedValueList()
|
|||
m_heap.did_destroy_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
void MarkedValueList::append(Value value)
|
||||
{
|
||||
m_values.append(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
class MarkedValueList {
|
||||
class MarkedValueList : public AK::Vector<Value, 32> {
|
||||
AK_MAKE_NONCOPYABLE(MarkedValueList);
|
||||
|
||||
public:
|
||||
|
@ -43,16 +43,16 @@ public:
|
|||
|
||||
MarkedValueList& operator=(MarkedValueList&&) = delete;
|
||||
|
||||
bool is_empty() const { return m_values.is_empty(); }
|
||||
size_t size() const { return m_values.size(); }
|
||||
void clear() { m_values.clear(); }
|
||||
Vector<Value, 32>& values() { return m_values; }
|
||||
Vector<Value, 32>& values() { return *this; }
|
||||
|
||||
void append(Value);
|
||||
MarkedValueList copy() const
|
||||
{
|
||||
MarkedValueList copy { m_heap };
|
||||
copy.append(*this);
|
||||
return copy;
|
||||
}
|
||||
|
||||
private:
|
||||
Heap& m_heap;
|
||||
Vector<Value, 32> m_values;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue