diff options
author | Eike Rathke <erack@redhat.com> | 2017-10-23 15:12:22 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-10-23 16:17:18 +0200 |
commit | 443113383296ca4781fb44e58e018a337db8e73c (patch) | |
tree | 5c4ac9cf5a9f3e1c067817775bc61eb1551e67fd | |
parent | Resolves: tdf#113336 avoid crash during teardown (diff) | |
download | core-443113383296ca4781fb44e58e018a337db8e73c.tar.gz core-443113383296ca4781fb44e58e018a337db8e73c.zip |
Move GetElementsMax() to .cxx
Nothing else is using it so we don't need it in .hxx
Change-Id: I0df879a7be2c56a70c30f50f44a92bb527b5a9ed
-rw-r--r-- | sc/inc/scmatrix.hxx | 17 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 19 |
2 files changed, 18 insertions, 18 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index c80ce3333ab0..4acd2c937f91 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -152,23 +152,6 @@ public: mfFirst(r.mfFirst), mfRest(r.mfRest), mnCount(r.mnCount) {} }; - /// The maximum number of elements a matrix may have at runtime. - static size_t GetElementsMax() - { - // Arbitrarily assuming 12 bytes per element, 8 bytes double plus - // overhead. Stored as an array in an mdds container it's less, but for - // strings or mixed matrix it can be much more.. - constexpr size_t nPerElem = 12; - // Arbitrarily assuming 1GB memory. Could be dynamic at some point. - constexpr size_t nMemMax = 0x40000000; - // With 1GB that's ~85M elements, or 85 whole columns. - constexpr size_t nElemMax = nMemMax / nPerElem; - // With MAXROWCOUNT==1048576 and 128 columns => 128M elements, 1.5GB - constexpr size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128; - // With the constant 1GB from above that's the actual value. - return nElemMax < nArbitraryLimit ? nElemMax : nArbitraryLimit; - } - /** Checks nC or nR for zero and uses GetElementsMax() whether a matrix of the size of nC*nR could be allocated. A zero size (both nC and nR zero) matrix is allowed for later resize. diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 7df5dbe52793..9fa822fad412 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -339,6 +339,23 @@ private: static bool bElementsMaxFetched; static size_t nElementsMax; +/// The maximum number of elements a matrix may have at runtime. +static size_t GetElementsMax() +{ + // Arbitrarily assuming 12 bytes per element, 8 bytes double plus + // overhead. Stored as an array in an mdds container it's less, but for + // strings or mixed matrix it can be much more.. + constexpr size_t nPerElem = 12; + // Arbitrarily assuming 1GB memory. Could be dynamic at some point. + constexpr size_t nMemMax = 0x40000000; + // With 1GB that's ~85M elements, or 85 whole columns. + constexpr size_t nElemMax = nMemMax / nPerElem; + // With MAXROWCOUNT==1048576 and 128 columns => 128M elements, 1.5GB + constexpr size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128; + // With the constant 1GB from above that's the actual value. + return nElemMax < nArbitraryLimit ? nElemMax : nArbitraryLimit; +} + ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) : maMat(nR, nC), maMatFlag(nR, nC), pErrorInterpreter(nullptr) { @@ -2781,7 +2798,7 @@ bool ScMatrix::IsSizeAllocatable( SCSIZE nC, SCSIZE nR ) if (!bElementsMaxFetched) { nElementsMax = std::getenv("SC_MAX_MATRIX_ELEMENTS") ? std::atoi(std::getenv("SC_MAX_MATRIX_ELEMENTS")) - : ScMatrix::GetElementsMax(); + : GetElementsMax(); bElementsMaxFetched = true; } |