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 /sc/source | |
parent | 4fc4b3360de37d48cebaa7b7498ce544aeadc2d8 (diff) |
Move GetElementsMax() to .cxx
Nothing else is using it so we don't need it in .hxx
Change-Id: I0df879a7be2c56a70c30f50f44a92bb527b5a9ed
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
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; } |