diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-27 16:09:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-28 11:45:56 +0200 |
commit | 6c724e18c2af227c2ad865342531ff35b0d511ac (patch) | |
tree | 837d68a7be72c9fb4beeb9f59b8ccb1e2e348ef4 | |
parent | 7e3c2e46c61c4ff29b4f4e62aa7a7660042d091e (diff) |
use more string_view in i18nlangtag
Change-Id: I92e3d60180c31d765994a2212e1c4547c09c93d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133517
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | i18nlangtag/source/isolang/isolang.cxx | 28 | ||||
-rw-r--r-- | include/i18nlangtag/mslangid.hxx | 4 |
2 files changed, 16 insertions, 16 deletions
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx index e8a50c6ea02f..d374bcd62213 100644 --- a/i18nlangtag/source/isolang/isolang.cxx +++ b/i18nlangtag/source/isolang/isolang.cxx @@ -1455,34 +1455,34 @@ IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] = // static LanguageType MsLangId::convertUnxByteStringToLanguage( - const OString& rString ) + std::string_view rString ) { OString aLang; OString aCountry; OString aAtString; - sal_Int32 nLangSepPos = rString.indexOf( '_' ); - sal_Int32 nCountrySepPos = rString.indexOf( '.' ); - sal_Int32 nAtPos = rString.indexOf( '@' ); + size_t nLangSepPos = rString.find( '_' ); + size_t nCountrySepPos = rString.find( '.' ); + size_t nAtPos = rString.find( '@' ); - if (nCountrySepPos < 0) + if (nCountrySepPos == std::string_view::npos) nCountrySepPos = nAtPos; - if (nCountrySepPos < 0) - nCountrySepPos = rString.getLength(); + if (nCountrySepPos == std::string_view::npos) + nCountrySepPos = rString.size(); - if (nAtPos >= 0) - aAtString = rString.copy( nAtPos+1 ); + if (nAtPos != std::string_view::npos) + aAtString = OString(rString.substr( nAtPos+1 )); - if (((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos)) || (nLangSepPos < 0)) + if (((nLangSepPos != std::string_view::npos) && (nLangSepPos > nCountrySepPos)) || (nLangSepPos == std::string_view::npos)) { // eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15" - aLang = rString.copy( 0, nCountrySepPos ); + aLang = OString(rString.substr( 0, nCountrySepPos )); } - else if ( nLangSepPos >= 0 ) + else if ( nLangSepPos != std::string_view::npos ) { // well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia" - aLang = rString.copy( 0, nLangSepPos ); - aCountry = rString.copy( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1); + aLang = OString(rString.substr( 0, nLangSepPos )); + aCountry = OString(rString.substr( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1)); } // if there is a glibc modifier, first look for exact match in modifier table diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx index aee1f23eb816..cb2e244556b1 100644 --- a/include/i18nlangtag/mslangid.hxx +++ b/include/i18nlangtag/mslangid.hxx @@ -120,7 +120,7 @@ public: // TODO: refactor to LanguageTag, used only in // i18npool/source/isolang/inunx.cxx to convert Unix locale string - static LanguageType convertUnxByteStringToLanguage( const OString& rString ); + static LanguageType convertUnxByteStringToLanguage( std::string_view rString ); static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType ); @@ -245,7 +245,7 @@ public: const css::lang::Locale & rLocale ); friend LanguageType MsLangId::convertUnxByteStringToLanguage( - const OString& rString ); + std::string_view rString ); /** Convert a Locale to a LanguageType with handling of an empty |