summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-14 22:13:51 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-15 07:47:25 +0100
commit8ec3222d47ef5a13921576569a700785378916a8 (patch)
treef60109c8b2ca88bb72d08b8a7a0be0478be68fbb
parent74e2ccfcbb31f0173acf058dfe938d0b16b6f9d2 (diff)
Do not initialize array at each function call
The function-local symbol prevented inlining in some cases, and needed a memcpy of 3200 bytes on each call. Change-Id: If2bd59d4bfc2a91e891cb0975847b7afebfbca23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110888 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--include/o3tl/unit_conversion.hxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/o3tl/unit_conversion.hxx b/include/o3tl/unit_conversion.hxx
index 17dd5ae12293..e43ecb557789 100644
--- a/include/o3tl/unit_conversion.hxx
+++ b/include/o3tl/unit_conversion.hxx
@@ -178,16 +178,16 @@ constexpr m_and_d mdBaseLen[] = {
static_assert(SAL_N_ELEMENTS(mdBaseLen) == static_cast<int>(Length::count),
"mdBaseL must have an entry for each unit in o3tl::Length");
+// The resulting multipliers and divisors array
+constexpr auto aLengthMDArray = prepareMDArray(mdBaseLen);
+
// an overload taking Length
constexpr sal_Int64 md(Length i, Length j)
{
- // The resulting multipliers and divisors array
- constexpr auto aMDArray = prepareMDArray(mdBaseLen);
-
const int nI = static_cast<int>(i), nJ = static_cast<int>(j);
- assert(nI >= 0 && o3tl::make_unsigned(nI) < aMDArray.size());
- assert(nJ >= 0 && o3tl::make_unsigned(nJ) < aMDArray.size());
- return aMDArray[nI][nJ];
+ assert(nI >= 0 && o3tl::make_unsigned(nI) < aLengthMDArray.size());
+ assert(nJ >= 0 && o3tl::make_unsigned(nJ) < aLengthMDArray.size());
+ return aLengthMDArray[nI][nJ];
}
// here might go overloads of md() taking other units ...