remove a double lookup in the cell map during serialisation

This commit is contained in:
JCrawfy 2020-03-01 23:18:13 +13:00
parent 932fc4596f
commit c418c13010
3 changed files with 19 additions and 7 deletions

View File

@ -199,7 +199,7 @@ cell::cell(detail::cell_impl *d)
bool cell::garbage_collectible() const
{
return !(has_value() || is_merged() || phonetics_visible() || has_formula() || has_format() || has_hyperlink());
return d_->is_garbage_collectible();
}
void cell::value(std::nullptr_t)

View File

@ -65,6 +65,11 @@ struct cell_impl
optional<hyperlink_impl> hyperlink_;
optional<format_impl *> format_;
optional<comment *> comment_;
bool is_garbage_collectible() const
{
return !(type_ != cell_type::empty || is_merged_ || phonetics_visible_ || formula_.is_set() || format_.is_set() || hyperlink_.is_set());
}
};
inline bool operator==(const cell_impl &lhs, const cell_impl &rhs)

View File

@ -2483,12 +2483,19 @@ void xlsx_producer::write_worksheet(const relationship &rel)
{
for (auto column = dimension.top_left().column(); column <= dimension.bottom_right().column(); ++column)
{
if (!ws.has_cell(cell_reference(column, check_row))) continue;
auto cell = ws.cell(cell_reference(column, check_row));
if (cell.garbage_collectible()) continue;
auto ref = cell_reference(column, check_row);
auto cell = ws.d_->cell_map_.find(ref);
if (cell == ws.d_->cell_map_.end())
{
continue;
}
if (cell->second.is_garbage_collectible())
{
continue;
}
first_block_column = std::min(first_block_column, cell.column());
last_block_column = std::max(last_block_column, cell.column());
first_block_column = std::min(first_block_column, cell->second.column_);
last_block_column = std::max(last_block_column, cell->second.column_);
if (row == check_row)
{