ladybird/Userland/Libraries/LibSQL/Key.cpp
Jan de Visser a5e28f2897 LibSQL: Make TupleDescriptor a shared pointer instead of a stack object
Tuple descriptors are basically the same for for example all rows in
a table. Makes sense to share them instead of copying them for every
single row.
2021-08-21 22:03:30 +02:00

39 lines
691 B
C++

/*
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibSQL/Key.h>
#include <LibSQL/Meta.h>
namespace SQL {
Key::Key()
: Tuple()
{
}
Key::Key(NonnullRefPtr<TupleDescriptor> const& descriptor)
: Tuple(descriptor)
{
}
Key::Key(NonnullRefPtr<IndexDef> index)
: Tuple(index->to_tuple_descriptor())
, m_index(index)
{
}
Key::Key(NonnullRefPtr<TupleDescriptor> const& descriptor, ByteBuffer& buffer, size_t& offset)
: Tuple(descriptor, buffer, offset)
{
}
Key::Key(RefPtr<IndexDef> index, ByteBuffer& buffer, size_t& offset)
: Key(index->to_tuple_descriptor())
{
deserialize(buffer, offset);
}
}