From 0b66d4a3d4892dc0751df5e0b00cb7a54cfb62bd Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 1 Mar 2023 10:40:03 +0100 Subject: Don't use unnamed namespace in qlocale_p.h Pointed out by CodeChecker. It's included by plenty of places, so duplicating that anonymous namespace potential code duplication. Use QtPrivate namespace instead. Change-Id: I9ccfd569089ea01a8be9ffd87889bca73b70dd9c Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/text/qlocale.cpp | 2 +- src/corelib/text/qlocale_p.h | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/corelib/text') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index b9807735e3..6202bfdfbb 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3920,7 +3920,7 @@ class NumericTokenizer // TODO: use deterministic finite-state-automata. // TODO QTBUG-95460: CLDR has Inf/NaN representations per locale. static constexpr char lettersInfNaN[] = "afin"; // Letters of Inf, NaN - static constexpr auto matchInfNaN = makeCharacterSetMatch(); + static constexpr auto matchInfNaN = QtPrivate::makeCharacterSetMatch(); const QStringView m_text; const QLocaleData::NumericData m_guide; qsizetype m_index = 0; diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index 99b2528633..fdf6889748 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -55,8 +55,8 @@ template struct QCharacterSetMatch } }; -namespace { -static constexpr char ascii_space_chars[] = +namespace QtPrivate { +inline constexpr char ascii_space_chars[] = "\t" // 9: HT - horizontal tab "\n" // 10: LF - line feed "\v" // 11: VT - vertical tab @@ -64,7 +64,8 @@ static constexpr char ascii_space_chars[] = "\r" // 13: CR - carriage return " "; // 32: space -template static constexpr auto makeCharacterSetMatch() +template +inline constexpr auto makeCharacterSetMatch() { constexpr auto view = std::string_view(Set); constexpr uchar MinElement = *std::min_element(view.begin(), view.end()); @@ -87,7 +88,7 @@ template static constexpr auto makeChar return QCharacterSetMatch(view); } } -} // unnamed namespace +} // QtPrivate struct QLocaleData; // Subclassed by Android platform plugin: @@ -536,7 +537,7 @@ QString qt_readEscapedFormatString(QStringView format, qsizetype *idx); [[nodiscard]] constexpr inline bool ascii_isspace(uchar c) { - constexpr auto matcher = makeCharacterSetMatch(); + constexpr auto matcher = QtPrivate::makeCharacterSetMatch(); return matcher.matches(c); } -- cgit v1.2.3