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