Skip to content

Commit

Permalink
LibJS: Make MarkedValueList inherit from Vector<Value>
Browse files Browse the repository at this point in the history
This makes the nicer vector API available to MVL without extra wrapper
functions.
  • Loading branch information
alimpfard authored and awesomekling committed Sep 8, 2020
1 parent 9a00699 commit 8d9c5a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
9 changes: 2 additions & 7 deletions Libraries/LibJS/Runtime/MarkedValueList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -47,9 +47,4 @@ MarkedValueList::~MarkedValueList()
m_heap.did_destroy_marked_value_list({}, *this);
}

void MarkedValueList::append(Value value)
{
m_values.append(value);
}

}
16 changes: 8 additions & 8 deletions Libraries/LibJS/Runtime/MarkedValueList.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

namespace JS {

class MarkedValueList {
class MarkedValueList : public AK::Vector<Value, 32> {
AK_MAKE_NONCOPYABLE(MarkedValueList);

public:
Expand All @@ -43,16 +43,16 @@ class MarkedValueList {

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;
};

}

0 comments on commit 8d9c5a8

Please sign in to comment.