mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibSQL: Remove and update VERIFY
s
We are performing a lot of checks on pointers that are performed again immediately afterwards because of a dereference. This removes the redundant `VERIFY`s and simplifies a couple others.
This commit is contained in:
parent
036eb82aca
commit
8992ff5aeb
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/8992ff5aeb Pull-request: https://github.com/SerenityOS/serenity/pull/18476 Reviewed-by: https://github.com/trflynn89 ✅
@ -65,7 +65,6 @@ bool BTree::insert(Key const& key)
|
||||
{
|
||||
if (!m_root)
|
||||
initialize_root();
|
||||
VERIFY(m_root);
|
||||
return m_root->insert(key);
|
||||
}
|
||||
|
||||
@ -73,7 +72,6 @@ bool BTree::update_key_pointer(Key const& key)
|
||||
{
|
||||
if (!m_root)
|
||||
initialize_root();
|
||||
VERIFY(m_root);
|
||||
return m_root->update_key_pointer(key);
|
||||
}
|
||||
|
||||
@ -81,7 +79,6 @@ Optional<u32> BTree::get(Key& key)
|
||||
{
|
||||
if (!m_root)
|
||||
initialize_root();
|
||||
VERIFY(m_root);
|
||||
return m_root->get(key);
|
||||
}
|
||||
|
||||
@ -89,7 +86,6 @@ BTreeIterator BTree::find(Key const& key)
|
||||
{
|
||||
if (!m_root)
|
||||
initialize_root();
|
||||
VERIFY(m_root);
|
||||
for (auto node = m_root->node_for(key); node; node = node->up()) {
|
||||
for (auto ix = 0u; ix < node->size(); ix++) {
|
||||
auto match = (*node)[ix].match(key);
|
||||
|
@ -187,13 +187,11 @@ Key const& HashBucket::operator[](size_t ix)
|
||||
{
|
||||
if (!m_inflated)
|
||||
m_hash_index.serializer().deserialize_block_to(pointer(), *this);
|
||||
VERIFY(ix < size());
|
||||
return m_entries[ix];
|
||||
}
|
||||
|
||||
Key const& HashBucket::operator[](size_t ix) const
|
||||
{
|
||||
VERIFY(ix < m_entries.size());
|
||||
return m_entries[ix];
|
||||
}
|
||||
|
||||
|
@ -70,13 +70,11 @@ public:
|
||||
|
||||
u32 user_value(size_t index) const
|
||||
{
|
||||
VERIFY(index < m_user_values.size());
|
||||
return m_user_values[index];
|
||||
}
|
||||
|
||||
void set_user_value(size_t index, u32 value)
|
||||
{
|
||||
VERIFY(index < m_user_values.size());
|
||||
m_user_values[index] = value;
|
||||
update_zero_block();
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ public:
|
||||
|
||||
void get_block(u32 pointer)
|
||||
{
|
||||
VERIFY(m_heap.ptr() != nullptr);
|
||||
auto buffer_or_error = m_heap->read_block(pointer);
|
||||
if (buffer_or_error.is_error())
|
||||
VERIFY_NOT_REACHED();
|
||||
@ -110,7 +109,7 @@ public:
|
||||
template<typename T>
|
||||
bool serialize_and_write(T const& t)
|
||||
{
|
||||
VERIFY(m_heap.ptr() != nullptr);
|
||||
VERIFY(!m_heap.is_null());
|
||||
reset();
|
||||
serialize<T>(t);
|
||||
m_heap->add_to_wal(t.pointer(), m_buffer);
|
||||
@ -120,20 +119,17 @@ public:
|
||||
[[nodiscard]] size_t offset() const { return m_current_offset; }
|
||||
u32 new_record_pointer()
|
||||
{
|
||||
VERIFY(m_heap.ptr() != nullptr);
|
||||
return m_heap->new_record_pointer();
|
||||
}
|
||||
|
||||
bool has_block(u32 pointer) const
|
||||
{
|
||||
VERIFY(m_heap.ptr() != nullptr);
|
||||
return pointer < m_heap->size();
|
||||
}
|
||||
|
||||
Heap& heap()
|
||||
{
|
||||
VERIFY(m_heap.ptr() != nullptr);
|
||||
return *(m_heap.ptr());
|
||||
return *m_heap;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -68,7 +68,6 @@ public:
|
||||
|
||||
[[nodiscard]] auto const& value() const
|
||||
{
|
||||
VERIFY(m_value.has_value());
|
||||
return *m_value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user