mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
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.
This commit is contained in:
parent
9e225d2d05
commit
a5e28f2897
17 changed files with 95 additions and 94 deletions
|
@ -28,9 +28,9 @@ namespace SQL {
|
|||
class Tuple {
|
||||
public:
|
||||
Tuple();
|
||||
explicit Tuple(TupleDescriptor const&, u32 pointer = 0);
|
||||
Tuple(TupleDescriptor const&, ByteBuffer&, size_t&);
|
||||
Tuple(TupleDescriptor const&, ByteBuffer&);
|
||||
explicit Tuple(NonnullRefPtr<TupleDescriptor> const&, u32 pointer = 0);
|
||||
Tuple(NonnullRefPtr<TupleDescriptor> const&, ByteBuffer&, size_t&);
|
||||
Tuple(NonnullRefPtr<TupleDescriptor> const&, ByteBuffer&);
|
||||
Tuple(Tuple const&);
|
||||
virtual ~Tuple() = default;
|
||||
|
||||
|
@ -61,14 +61,14 @@ public:
|
|||
[[nodiscard]] u32 pointer() const { return m_pointer; }
|
||||
void set_pointer(u32 ptr) { m_pointer = ptr; }
|
||||
|
||||
[[nodiscard]] size_t size() const;
|
||||
[[nodiscard]] size_t length() const { return m_descriptor.size(); }
|
||||
[[nodiscard]] TupleDescriptor descriptor() const { return m_descriptor; }
|
||||
[[nodiscard]] size_t size() const { return m_data.size(); }
|
||||
[[nodiscard]] size_t length() const { return m_descriptor->size(); }
|
||||
[[nodiscard]] NonnullRefPtr<TupleDescriptor> descriptor() const { return m_descriptor; }
|
||||
[[nodiscard]] int compare(Tuple const&) const;
|
||||
[[nodiscard]] int match(Tuple const&) const;
|
||||
[[nodiscard]] u32 hash() const;
|
||||
virtual void serialize(ByteBuffer&) const;
|
||||
[[nodiscard]] virtual size_t data_length() const { return descriptor().data_length(); }
|
||||
[[nodiscard]] virtual size_t data_length() const { return descriptor()->data_length(); }
|
||||
|
||||
protected:
|
||||
[[nodiscard]] Optional<size_t> index_of(String) const;
|
||||
|
@ -76,7 +76,7 @@ protected:
|
|||
void deserialize(ByteBuffer&, size_t&);
|
||||
|
||||
private:
|
||||
TupleDescriptor m_descriptor;
|
||||
NonnullRefPtr<TupleDescriptor> m_descriptor;
|
||||
Vector<Value> m_data;
|
||||
u32 m_pointer { 0 };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue