mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
remove a double lookup in the cell map during serialisation
This commit is contained in:
parent
932fc4596f
commit
c418c13010
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user