susumu.yata
null+****@clear*****
Tue Aug 13 18:05:23 JST 2013
susumu.yata 2013-08-13 18:05:23 +0900 (Tue, 13 Aug 2013) New Revision: 63a2abd0726a0268c7a1ec1fd7bcb13545732afd https://github.com/groonga/grnxx/commit/63a2abd0726a0268c7a1ec1fd7bcb13545732afd Message: Remove an unnecessary member variable table_size_. Modified files: lib/grnxx/map/pool.cpp lib/grnxx/map/pool.hpp Modified: lib/grnxx/map/pool.cpp (+9 -10) =================================================================== --- lib/grnxx/map/pool.cpp 2013-08-13 17:12:00 +0900 (aee3ea4) +++ lib/grnxx/map/pool.cpp 2013-08-13 18:05:23 +0900 (deccdfa) @@ -54,7 +54,6 @@ Pool<T>::Pool() pages_(), table_(nullptr), size_(0), - table_size_(0), queue_() {} template <typename T> @@ -281,20 +280,20 @@ void Pool<T>::expand_pool() { header_->page_storage_node_id = page_node.id(); } else { // Create a table. - uint64_t new_table_size = new_size / PAGE_SIZE; - if (new_table_size < MIN_TABLE_SIZE) { - new_size = PAGE_SIZE * MIN_TABLE_SIZE; - new_table_size = MIN_TABLE_SIZE; - } + const uint64_t old_table_size = + (size_ <= PAGE_SIZE) ? 0 : (size_ / PAGE_SIZE); + const uint64_t new_table_size = + (old_table_size == 0) ? MIN_TABLE_SIZE : (old_table_size * 2); + new_size = new_table_size * PAGE_SIZE; StorageNode table_node = storage_->create_node( storage_node_id_, sizeof(uint32_t) * new_table_size); uint32_t * const new_table = static_cast<uint32_t *>(table_node.body()); uint64_t i; - if (table_size_ == 0) { + if (old_table_size == 0) { new_table[0] = header_->page_storage_node_id; i = 1; } else { - for (i = 0; i < table_size_; ++i) { + for (i = 0; i < old_table_size; ++i) { new_table[i] = table_[i]; } } @@ -343,8 +342,9 @@ void Pool<T>::refresh_pool() { throw MemoryError(); } // Initialize a new cache table. + const uint64_t old_table_size = size_ / PAGE_SIZE; uint64_t i = 0; - for ( ; i < table_size_; ++i) { + for ( ; i < old_table_size; ++i) { new_pages[i] = pages_[i]; } for ( ; i < new_table_size; ++i) { @@ -362,7 +362,6 @@ void Pool<T>::refresh_pool() { } } table_ = new_table; - table_size_ = new_table_size; } size_ = header_->size; } Modified: lib/grnxx/map/pool.hpp (+0 -1) =================================================================== --- lib/grnxx/map/pool.hpp 2013-08-13 17:12:00 +0900 (7e4821a) +++ lib/grnxx/map/pool.hpp 2013-08-13 18:05:23 +0900 (796eef1) @@ -139,7 +139,6 @@ class Pool { std::unique_ptr<void *[]> pages_; uint32_t *table_; uint64_t size_; - uint64_t table_size_; // TODO: Time must be added. std::queue<std::unique_ptr<void *[]>> queue_; -------------- next part -------------- HTML����������������������������... 下載