1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibSQL: Don't copy strings when searching for a column's index

Also don't cast the return value to an int.
This commit is contained in:
Timothy Flynn 2022-11-27 10:20:14 -05:00 committed by Linus Groh
parent c3a6fad080
commit 47dd1b9f8b
2 changed files with 4 additions and 5 deletions

View file

@ -79,13 +79,12 @@ Tuple& Tuple::operator=(Tuple const& other)
return *this; return *this;
} }
Optional<size_t> Tuple::index_of(String name) const Optional<size_t> Tuple::index_of(StringView name) const
{ {
auto n = move(name);
for (auto ix = 0u; ix < m_descriptor->size(); ix++) { for (auto ix = 0u; ix < m_descriptor->size(); ix++) {
auto& part = (*m_descriptor)[ix]; auto& part = (*m_descriptor)[ix];
if (part.name == n) { if (part.name == name) {
return (int)ix; return ix;
} }
} }
return {}; return {};

View file

@ -70,7 +70,7 @@ public:
[[nodiscard]] u32 hash() const; [[nodiscard]] u32 hash() const;
protected: protected:
[[nodiscard]] Optional<size_t> index_of(String) const; [[nodiscard]] Optional<size_t> index_of(StringView) const;
void copy_from(Tuple const&); void copy_from(Tuple const&);
virtual void serialize(Serializer&) const; virtual void serialize(Serializer&) const;
virtual void deserialize(Serializer&); virtual void deserialize(Serializer&);