mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00: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
5 changed files with 2 additions and 15 deletions
|
@ -65,7 +65,6 @@ bool BTree::insert(Key const& key)
|
||||||
{
|
{
|
||||||
if (!m_root)
|
if (!m_root)
|
||||||
initialize_root();
|
initialize_root();
|
||||||
VERIFY(m_root);
|
|
||||||
return m_root->insert(key);
|
return m_root->insert(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +72,6 @@ bool BTree::update_key_pointer(Key const& key)
|
||||||
{
|
{
|
||||||
if (!m_root)
|
if (!m_root)
|
||||||
initialize_root();
|
initialize_root();
|
||||||
VERIFY(m_root);
|
|
||||||
return m_root->update_key_pointer(key);
|
return m_root->update_key_pointer(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +79,6 @@ Optional<u32> BTree::get(Key& key)
|
||||||
{
|
{
|
||||||
if (!m_root)
|
if (!m_root)
|
||||||
initialize_root();
|
initialize_root();
|
||||||
VERIFY(m_root);
|
|
||||||
return m_root->get(key);
|
return m_root->get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +86,6 @@ BTreeIterator BTree::find(Key const& key)
|
||||||
{
|
{
|
||||||
if (!m_root)
|
if (!m_root)
|
||||||
initialize_root();
|
initialize_root();
|
||||||
VERIFY(m_root);
|
|
||||||
for (auto node = m_root->node_for(key); node; node = node->up()) {
|
for (auto node = m_root->node_for(key); node; node = node->up()) {
|
||||||
for (auto ix = 0u; ix < node->size(); ix++) {
|
for (auto ix = 0u; ix < node->size(); ix++) {
|
||||||
auto match = (*node)[ix].match(key);
|
auto match = (*node)[ix].match(key);
|
||||||
|
|
|
@ -187,13 +187,11 @@ Key const& HashBucket::operator[](size_t ix)
|
||||||
{
|
{
|
||||||
if (!m_inflated)
|
if (!m_inflated)
|
||||||
m_hash_index.serializer().deserialize_block_to(pointer(), *this);
|
m_hash_index.serializer().deserialize_block_to(pointer(), *this);
|
||||||
VERIFY(ix < size());
|
|
||||||
return m_entries[ix];
|
return m_entries[ix];
|
||||||
}
|
}
|
||||||
|
|
||||||
Key const& HashBucket::operator[](size_t ix) const
|
Key const& HashBucket::operator[](size_t ix) const
|
||||||
{
|
{
|
||||||
VERIFY(ix < m_entries.size());
|
|
||||||
return m_entries[ix];
|
return m_entries[ix];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,13 +70,11 @@ public:
|
||||||
|
|
||||||
u32 user_value(size_t index) const
|
u32 user_value(size_t index) const
|
||||||
{
|
{
|
||||||
VERIFY(index < m_user_values.size());
|
|
||||||
return m_user_values[index];
|
return m_user_values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_user_value(size_t index, u32 value)
|
void set_user_value(size_t index, u32 value)
|
||||||
{
|
{
|
||||||
VERIFY(index < m_user_values.size());
|
|
||||||
m_user_values[index] = value;
|
m_user_values[index] = value;
|
||||||
update_zero_block();
|
update_zero_block();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ public:
|
||||||
|
|
||||||
void get_block(u32 pointer)
|
void get_block(u32 pointer)
|
||||||
{
|
{
|
||||||
VERIFY(m_heap.ptr() != nullptr);
|
|
||||||
auto buffer_or_error = m_heap->read_block(pointer);
|
auto buffer_or_error = m_heap->read_block(pointer);
|
||||||
if (buffer_or_error.is_error())
|
if (buffer_or_error.is_error())
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -110,7 +109,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool serialize_and_write(T const& t)
|
bool serialize_and_write(T const& t)
|
||||||
{
|
{
|
||||||
VERIFY(m_heap.ptr() != nullptr);
|
VERIFY(!m_heap.is_null());
|
||||||
reset();
|
reset();
|
||||||
serialize<T>(t);
|
serialize<T>(t);
|
||||||
m_heap->add_to_wal(t.pointer(), m_buffer);
|
m_heap->add_to_wal(t.pointer(), m_buffer);
|
||||||
|
@ -120,20 +119,17 @@ public:
|
||||||
[[nodiscard]] size_t offset() const { return m_current_offset; }
|
[[nodiscard]] size_t offset() const { return m_current_offset; }
|
||||||
u32 new_record_pointer()
|
u32 new_record_pointer()
|
||||||
{
|
{
|
||||||
VERIFY(m_heap.ptr() != nullptr);
|
|
||||||
return m_heap->new_record_pointer();
|
return m_heap->new_record_pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_block(u32 pointer) const
|
bool has_block(u32 pointer) const
|
||||||
{
|
{
|
||||||
VERIFY(m_heap.ptr() != nullptr);
|
|
||||||
return pointer < m_heap->size();
|
return pointer < m_heap->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Heap& heap()
|
Heap& heap()
|
||||||
{
|
{
|
||||||
VERIFY(m_heap.ptr() != nullptr);
|
return *m_heap;
|
||||||
return *(m_heap.ptr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -68,7 +68,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] auto const& value() const
|
[[nodiscard]] auto const& value() const
|
||||||
{
|
{
|
||||||
VERIFY(m_value.has_value());
|
|
||||||
return *m_value;
|
return *m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue