Date: prev next · Thread: first prev next last
2020 Archives by date, by thread · List index


Hi Naruhiko,

On Thursday, 2020-05-14 19:40:19 +0900, Naruhiko Ogasawara wrote:

Now I'm trying to resolve tdf#130140 and tdf#130193, both of them
relate to the mapping between NatNum of Calc and DBNum of Excel.

Great you're looking into that!

static const std::map<LanguageType, std::vector<sal_uInt8>> tblDBNumToNatNum
    = { { primary(LANGUAGE_CHINESE),    { 4, 5, 6, 0 } },
        { primary(LANGUAGE_JAPANESE),   { 4, 5, 3, 0 } },
        { primary(LANGUAGE_KOREAN),     { 1, 2, 3, 9 } } };
[...]
          if (tblDBNumToNatNum.count(eLang) != 0)
        {
            nNatNum = tblDBNumToNatNum.at(eLang)[nDBNum - 1];
        }

Apart from the array vs vector problem, instead of counting the mapped
elements each time it would be more efficient to obtain a match (or
non-match) right away and use that, like (untested)

    auto const it = tblDBNumToNatNum.find(eLang);
    if (it != tblDBNumToNatNum.end())
        nNatNum = it->second[nDBNum - 1]

Also, as we have constant data here that isn't modified, using std::set
could be more appropriate than std::map.

  Eike

-- 
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A

Attachment: signature.asc
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.