include/o3tl/unit_conversion.hxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
New commits: commit 8ec3222d47ef5a13921576569a700785378916a8 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Feb 14 22:13:51 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Feb 15 07:47:25 2021 +0100 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.kagan...@collabora.com> 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 ... _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits