From 8332d6d8200e8ca1f22dd98d9373efd5a431d09c Mon Sep 17 00:00:00 2001 From: Noel Date: Wed, 25 Nov 2020 08:14:07 +0200 Subject: loplugin:stringviewparam include comparisons with string literals Change-Id: I8ba1214500dddaf413c506a4b82f43d63cda804b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106559 Tested-by: Jenkins Reviewed-by: Noel Grandin --- i18npool/inc/numberformatcode.hxx | 4 ++-- .../defaultnumberingprovider.cxx | 4 ++-- i18npool/source/localedata/LocaleNode.hxx | 2 +- i18npool/source/localedata/filewriter.cxx | 4 ++-- .../source/numberformatcode/numberformatcode.cxx | 26 +++++++++++----------- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'i18npool') diff --git a/i18npool/inc/numberformatcode.hxx b/i18npool/inc/numberformatcode.hxx index 47055edb8967..2b1a5006653d 100644 --- a/i18npool/inc/numberformatcode.hxx +++ b/i18npool/inc/numberformatcode.hxx @@ -62,9 +62,9 @@ private: const css::uno::Sequence< css::i18n::FormatElement >& getFormats( const css::lang::Locale& rLocale ); static OUString mapElementTypeShortToString(sal_Int16 formatType); - static sal_Int16 mapElementTypeStringToShort(const OUString& formatType); + static sal_Int16 mapElementTypeStringToShort(std::u16string_view formatType); static OUString mapElementUsageShortToString(sal_Int16 formatUsage); - static sal_Int16 mapElementUsageStringToShort(const OUString& formatUsage); + static sal_Int16 mapElementUsageStringToShort(std::u16string_view formatUsage); }; diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx index 119cc76b4f61..2d55e1fd0974 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -546,10 +546,10 @@ void lcl_formatCharsGR(const sal_Unicode table[], int n, OUString& s ) } static -bool should_ignore( const OUString& s ) +bool should_ignore( std::u16string_view s ) { // return true if blank or null - return s == " " || (!s.isEmpty() && s[0]==0); + return s == u" " || (!s.empty() && s[0]==0); } /** diff --git a/i18npool/source/localedata/LocaleNode.hxx b/i18npool/source/localedata/LocaleNode.hxx index f5990fcb772b..0d46a9e80876 100644 --- a/i18npool/source/localedata/LocaleNode.hxx +++ b/i18npool/source/localedata/LocaleNode.hxx @@ -49,7 +49,7 @@ public: void writeFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const; void writeRefFunction3(const char *func, const OUString& useLocale) const; void writeIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const; - bool writeDefaultParameter(const char* pAsciiStr, const OUString& str, sal_Int16 count) const; + bool writeDefaultParameter(const char* pAsciiStr, std::u16string_view str, sal_Int16 count) const; void writeParameter(const char* pAsciiStr, const OUString& aChars) const; void writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count) const; void writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const; diff --git a/i18npool/source/localedata/filewriter.cxx b/i18npool/source/localedata/filewriter.cxx index f4652fefd610..f8643025d91d 100644 --- a/i18npool/source/localedata/filewriter.cxx +++ b/i18npool/source/localedata/filewriter.cxx @@ -126,9 +126,9 @@ void OFileWriter::writeIntParameter(const char* pAsciiStr, const sal_Int16 count fprintf(m_f, "static const sal_Unicode %s%d[] = {%d};\n", pAsciiStr, count, val); } -bool OFileWriter::writeDefaultParameter(const char* pAsciiStr, const OUString& str, sal_Int16 count) const +bool OFileWriter::writeDefaultParameter(const char* pAsciiStr, std::u16string_view str, sal_Int16 count) const { - bool bBool = str == "true"; + bool bBool = str == u"true"; fprintf(m_f,"static const sal_Unicode default%s%d[] = {%d};\n", pAsciiStr, count, bBool); return bBool; } diff --git a/i18npool/source/numberformatcode/numberformatcode.cxx b/i18npool/source/numberformatcode/numberformatcode.cxx index c98a8b36c01e..90d6904b85a1 100644 --- a/i18npool/source/numberformatcode/numberformatcode.cxx +++ b/i18npool/source/numberformatcode/numberformatcode.cxx @@ -175,13 +175,13 @@ NumberFormatCodeMapper::mapElementTypeShortToString(sal_Int16 formatType) } sal_Int16 -NumberFormatCodeMapper::mapElementTypeStringToShort(const OUString& formatType) +NumberFormatCodeMapper::mapElementTypeStringToShort(std::u16string_view formatType) { - if ( formatType == "short" ) + if ( formatType == u"short" ) return css::i18n::KNumberFormatType::SHORT; - if ( formatType == "medium" ) + if ( formatType == u"medium" ) return css::i18n::KNumberFormatType::MEDIUM; - if ( formatType == "long" ) + if ( formatType == u"long" ) return css::i18n::KNumberFormatType::LONG; return css::i18n::KNumberFormatType::SHORT; @@ -214,23 +214,23 @@ NumberFormatCodeMapper::mapElementUsageShortToString(sal_Int16 formatUsage) sal_Int16 -NumberFormatCodeMapper::mapElementUsageStringToShort(const OUString& formatUsage) +NumberFormatCodeMapper::mapElementUsageStringToShort(std::u16string_view formatUsage) { - if ( formatUsage == "DATE" ) + if ( formatUsage == u"DATE" ) return css::i18n::KNumberFormatUsage::DATE; - if ( formatUsage == "TIME" ) + if ( formatUsage == u"TIME" ) return css::i18n::KNumberFormatUsage::TIME; - if ( formatUsage == "DATE_TIME" ) + if ( formatUsage == u"DATE_TIME" ) return css::i18n::KNumberFormatUsage::DATE_TIME; - if ( formatUsage == "FIXED_NUMBER" ) + if ( formatUsage == u"FIXED_NUMBER" ) return css::i18n::KNumberFormatUsage::FIXED_NUMBER; - if ( formatUsage == "FRACTION_NUMBER" ) + if ( formatUsage == u"FRACTION_NUMBER" ) return css::i18n::KNumberFormatUsage::FRACTION_NUMBER; - if ( formatUsage == "PERCENT_NUMBER" ) + if ( formatUsage == u"PERCENT_NUMBER" ) return css::i18n::KNumberFormatUsage::PERCENT_NUMBER; - if ( formatUsage == "CURRENCY" ) + if ( formatUsage == u"CURRENCY" ) return css::i18n::KNumberFormatUsage::CURRENCY; - if ( formatUsage == "SCIENTIFIC_NUMBER" ) + if ( formatUsage == u"SCIENTIFIC_NUMBER" ) return css::i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER; return 0; -- cgit