Spreadsheet: do not create string property for empty cell
Otherwise may cause massive slow down when, for example, the user changes the entire row/column color, which results in large amount of empty cells.
This commit is contained in:
@@ -288,6 +288,8 @@ void Cell::setContent(const char * value)
|
||||
clearException();
|
||||
if (value) {
|
||||
if (owner->sheet()->isRestoring()) {
|
||||
if (value[0] == '\0' || (value[0] == '\'' && value[1] == '\0'))
|
||||
return;
|
||||
expression.reset(new App::StringExpression(owner->sheet(), value));
|
||||
setUsed(EXPRESSION_SET, true);
|
||||
return;
|
||||
@@ -302,7 +304,10 @@ void Cell::setContent(const char * value)
|
||||
}
|
||||
}
|
||||
else if (*value == '\'') {
|
||||
newExpr = std::make_unique<App::StringExpression>(owner->sheet(), value + 1);
|
||||
if (value[1] == '\0')
|
||||
value = nullptr;
|
||||
else
|
||||
newExpr = std::make_unique<App::StringExpression>(owner->sheet(), value + 1);
|
||||
}
|
||||
else if (*value != '\0') {
|
||||
// check if value is just a number
|
||||
|
||||
@@ -683,10 +683,12 @@ void Sheet::updateProperty(CellAddress key)
|
||||
else {
|
||||
std::string s;
|
||||
|
||||
if (cell->getStringContent(s))
|
||||
if (cell->getStringContent(s) && !s.empty())
|
||||
output.reset(new StringExpression(this, s));
|
||||
else
|
||||
output.reset(new StringExpression(this, ""));
|
||||
else {
|
||||
this->removeDynamicProperty(key.toString().c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Eval returns either NumberExpression or StringExpression, or
|
||||
|
||||
Reference in New Issue
Block a user