Commit 9fcd740e authored by Kohei Yoshida's avatar Kohei Yoshida

Use deque to store column stores to reduce indirection levels.

parent d2640289
......@@ -18,6 +18,8 @@
#include <mdds/multi_type_vector_custom_func1.hpp>
#include <mdds/multi_type_matrix.hpp>
#include <deque>
namespace ixion {
// Element types
......@@ -45,7 +47,7 @@ using ixion_element_block_func = mdds::mtv::custom_block_func1<formula_element_b
using column_store_t = mdds::multi_type_vector<ixion_element_block_func>;
/** Type that represents a collection of columns. */
using column_stores_t = std::vector<column_store_t*>;
using column_stores_t = std::deque<column_store_t>;
/**
* The integer element blocks are used to store string ID's. The actual
......
......@@ -166,7 +166,7 @@ public:
if (!range.all_rows())
{
const column_store_t& col = *(*cols)[0];
const column_store_t& col = (*cols)[0];
row_t r1 = range.first.row == row_unset ? 0 : range.first.row;
row_t r2 = range.last.row == row_unset ? (col.size() - 1) : range.last.row;
assert(r1 >= 0);
......@@ -269,7 +269,7 @@ public:
if (m_it_cols_begin == m_it_cols_end)
return;
m_row_last = (*m_cols)[0]->size() - 1;
m_row_last = (*m_cols)[0].size() - 1;
if (range.valid())
{
......@@ -317,7 +317,7 @@ public:
}
}
const column_store_t& col = **m_it_cols;
const column_store_t& col = *m_it_cols;
m_current_pos = col.position(m_row_first);
m_end_pos = col.position(m_row_last+1);
}
......@@ -335,7 +335,7 @@ public:
m_update_current_cell = true;
m_current_pos = column_store_t::next_position(m_current_pos);
const column_store_t* col = *m_it_cols;
const column_store_t* col = &*m_it_cols;
if (m_current_pos != m_end_pos)
// It hasn't reached the end of the current column yet.
return;
......@@ -345,7 +345,7 @@ public:
return;
// Reset the position to the first cell in the new column.
col = *m_it_cols;
col = &*m_it_cols;
m_current_pos = col->position(m_row_first);
m_end_pos = col->position(m_row_last+1);
}
......
......@@ -15,26 +15,22 @@ worksheet::worksheet() {}
worksheet::worksheet(size_t row_size, size_t col_size)
{
m_columns.reserve(col_size);
m_pos_hints.reserve(col_size);
for (size_t i = 0; i < col_size; ++i)
{
m_columns.push_back(new column_store_t(row_size));
m_pos_hints.push_back(m_columns.back()->begin());
m_columns.emplace_back(row_size);
m_pos_hints.push_back(m_columns.back().begin());
}
}
worksheet::~worksheet()
{
std::for_each(m_columns.begin(), m_columns.end(), default_deleter<column_store_t>());
}
worksheet::~worksheet() {}
rc_size_t worksheet::get_sheet_size() const
{
if (m_columns.empty())
return rc_size_t(0, 0);
return rc_size_t(m_columns[0]->size(), m_columns.size());
return rc_size_t(m_columns[0].size(), m_columns.size());
}
workbook::workbook() {}
......
......@@ -24,11 +24,11 @@ public:
worksheet(size_type row_size, size_type col_size);
~worksheet();
column_store_t& operator[](size_type n) { return *m_columns[n]; }
const column_store_t& operator[](size_type n) const { return *m_columns[n]; }
column_store_t& operator[](size_type n) { return m_columns[n]; }
const column_store_t& operator[](size_type n) const { return m_columns[n]; }
column_store_t& at(size_type n) { return *m_columns.at(n); }
const column_store_t& at(size_type n) const { return *m_columns.at(n); }
column_store_t& at(size_type n) { return m_columns.at(n); }
const column_store_t& at(size_type n) const { return m_columns.at(n); }
column_store_t::iterator& get_pos_hint(size_type n) { return m_pos_hints.at(n); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment