From 98e60805613ab6ea19c03c34c0f36d00374dab73 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 28 Jan 2019 16:24:09 +0200 Subject: loplugin:flatten in stoc..store Change-Id: Ib8c86179a3d13852cbb02b389b6103aca5456dba Reviewed-on: https://gerrit.libreoffice.org/67013 Tested-by: Jenkins Reviewed-by: Noel Grandin --- store/source/storcach.cxx | 58 +++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'store/source') diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx index 3fdf60ec13a0..76a0c6d185c8 100644 --- a/store/source/storcach.cxx +++ b/store/source/storcach.cxx @@ -220,42 +220,42 @@ void PageCache::rescale_Impl (std::size_t new_size) std::size_t new_bytes = new_size * sizeof(Entry*); Entry ** new_table = static_cast(std::malloc(new_bytes)); - if (new_table != nullptr) - { - Entry ** old_table = m_hash_table; - std::size_t old_size = m_hash_size; + if (new_table == nullptr) + return; - SAL_INFO( - "store", - "ave chain length: " << (m_hash_entries >> m_hash_shift) - << ", total entries: " << m_hash_entries << " [old_size: " - << old_size << " new_size: " << new_size << "]"); + Entry ** old_table = m_hash_table; + std::size_t old_size = m_hash_size; - memset (new_table, 0, new_bytes); + SAL_INFO( + "store", + "ave chain length: " << (m_hash_entries >> m_hash_shift) + << ", total entries: " << m_hash_entries << " [old_size: " + << old_size << " new_size: " << new_size << "]"); - m_hash_table = new_table; - m_hash_size = new_size; - m_hash_shift = highbit(m_hash_size) - 1; + memset (new_table, 0, new_bytes); - std::size_t i; - for (i = 0; i < old_size; i++) + m_hash_table = new_table; + m_hash_size = new_size; + m_hash_shift = highbit(m_hash_size) - 1; + + std::size_t i; + for (i = 0; i < old_size; i++) + { + Entry * curr = old_table[i]; + while (curr != nullptr) { - Entry * curr = old_table[i]; - while (curr != nullptr) - { - Entry * next = curr->m_pNext; - int index = hash_index_Impl(curr->m_nOffset); - curr->m_pNext = m_hash_table[index]; - m_hash_table[index] = curr; - curr = next; - } - old_table[i] = nullptr; + Entry * next = curr->m_pNext; + int index = hash_index_Impl(curr->m_nOffset); + curr->m_pNext = m_hash_table[index]; + m_hash_table[index] = curr; + curr = next; } - if (old_table != m_hash_table_0) - { + old_table[i] = nullptr; + } + if (old_table != m_hash_table_0) + { - std::free (old_table); - } + std::free (old_table); } } -- cgit