mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibSQL: Add the 'extend' operation to the Tuple class
Tuple::extend is similar to the Vector method of the same name; it concatenates a second Tuple to the current one.
This commit is contained in:
parent
f3a9d61891
commit
c2c47fb9bb
Notes:
sideshowbarker
2024-07-18 01:19:23 +09:00
Author: https://github.com/JanDeVisser Commit: https://github.com/SerenityOS/serenity/commit/c2c47fb9bba Pull-request: https://github.com/SerenityOS/serenity/pull/10770 Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 10 additions and 0 deletions
|
@ -132,6 +132,15 @@ Tuple& Tuple::operator+=(Value const& value)
|
|||
return *this;
|
||||
}
|
||||
|
||||
void Tuple::extend(Tuple const& other)
|
||||
{
|
||||
VERIFY((descriptor()->size() == size()) || (descriptor()->size() >= size() + other.size()));
|
||||
if (descriptor()->size() == size()) {
|
||||
descriptor()->extend(other.descriptor());
|
||||
}
|
||||
m_data.extend(other.m_data);
|
||||
}
|
||||
|
||||
bool Tuple::is_compatible(Tuple const& other) const
|
||||
{
|
||||
if ((m_descriptor->size() == 0) && (other.m_descriptor->size() == 0)) {
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
Value& operator[](String const& name);
|
||||
void append(Value const&);
|
||||
Tuple& operator+=(Value const&);
|
||||
void extend(Tuple const&);
|
||||
[[nodiscard]] bool is_compatible(Tuple const&) const;
|
||||
|
||||
[[nodiscard]] u32 pointer() const { return m_pointer; }
|
||||
|
|
Loading…
Reference in a new issue