[Libreoffice-commits] core.git: include/o3tl

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 15 06:48:03 UTC 2021


 include/o3tl/unit_conversion.hxx |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 8ec3222d47ef5a13921576569a700785378916a8
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Feb 14 22:13:51 2021 +0300
Commit:     Mike Kaganski <mike.kaganski at 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.kaganski at 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 ...


More information about the Libreoffice-commits mailing list