diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2018-09-18 15:01:29 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2018-10-10 12:59:39 +0200 |
commit | 16e417b8c211a919a921baeb65660185aac38393 (patch) | |
tree | c3cbc6d190fcc96a92694ed14e5961b7c57cc3ac /sc | |
parent | 7600c63424db644065d736158c182cb9498574e9 (diff) |
add ScTokenArray::Finalize() to explicitly reduce memory usage
Since ScTokenArray::Add() overallocates memory, make sure we do not
keep such possibly large arrays. Since any copying of ScTokenArray
implicitly finalizes as well, this is not a big problem right now,
but then why needlessly do the copies? (next commit)
Change-Id: I55398bcd8fb31f1be5a4b8e3f5a71b26649a7594
Reviewed-on: https://gerrit.libreoffice.org/60862
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 1684c0023759..84d0ba952cda 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -548,6 +548,7 @@ void ScFormulaCellGroup::setCode( ScTokenArray* pCode ) { delete mpCode; mpCode = pCode; // takes ownership of the token array. + mpCode->Finalize(); // Reduce memory usage if needed. mbInvariant = mpCode->IsInvariant(); mpCode->GenHash(); } @@ -699,6 +700,8 @@ ScFormulaCell::ScFormulaCell( { assert(pArray); // Never pass a NULL pointer here. + pCode->Finalize(); // Reduce memory usage if needed. + // Generate RPN token array. if (pCode->GetLen() && pCode->GetCodeError() == FormulaError::NONE && !pCode->GetCodeLen()) { @@ -722,7 +725,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray& rArray, const FormulaGrammar::Grammar eGrammar, ScMatrixMode cMatInd ) : eTempGrammar( eGrammar), - pCode(new ScTokenArray(rArray)), + pCode(new ScTokenArray(rArray)), // also implicitly does Finalize() on the array pDocument( pDoc ), pPrevious(nullptr), pNext(nullptr), |