Skip to content

Commit 187349e

Browse files
trflynn89awesomekling
authored andcommitted
LibLocale: Inline a couple of ICU string conversion methods
This just allows using the ICU header within LibUnicode, without having to link against LibLocale. Eventually, I think it will make sense to combine LibUnicode & LibLocale back into a single library. They were separated to remove the large CLDR data library from LibUnicode since most users did not need it. But that is not much of a concern now.
1 parent 1feef17 commit 187349e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Userland/Libraries/LibLocale/ICU.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <unicode/locdspnm.h>
1616
#include <unicode/numsys.h>
1717
#include <unicode/tznames.h>
18-
#include <unicode/unistr.h>
1918

2019
namespace Locale {
2120

@@ -116,16 +115,6 @@ icu::TimeZoneNames& LocaleData::time_zone_names()
116115
return *m_time_zone_names;
117116
}
118117

119-
icu::UnicodeString icu_string(StringView string)
120-
{
121-
return icu::UnicodeString::fromUTF8(icu_string_piece(string));
122-
}
123-
124-
icu::StringPiece icu_string_piece(StringView string)
125-
{
126-
return { string.characters_without_null_termination(), static_cast<i32>(string.length()) };
127-
}
128-
129118
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings)
130119
{
131120
Vector<icu::UnicodeString> result;

Userland/Libraries/LibLocale/ICU.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <unicode/locid.h>
1818
#include <unicode/stringpiece.h>
19+
#include <unicode/unistr.h>
1920
#include <unicode/utypes.h>
2021
#include <unicode/uversion.h>
2122

@@ -24,7 +25,6 @@ class DateTimePatternGenerator;
2425
class LocaleDisplayNames;
2526
class NumberingSystem;
2627
class TimeZoneNames;
27-
class UnicodeString;
2828
U_NAMESPACE_END
2929

3030
namespace Locale {
@@ -63,18 +63,25 @@ class LocaleData {
6363
Optional<DigitalFormat> m_digital_format;
6464
};
6565

66-
static constexpr bool icu_success(UErrorCode code)
66+
constexpr bool icu_success(UErrorCode code)
6767
{
6868
return static_cast<bool>(U_SUCCESS(code));
6969
}
7070

71-
static constexpr bool icu_failure(UErrorCode code)
71+
constexpr bool icu_failure(UErrorCode code)
7272
{
7373
return static_cast<bool>(U_FAILURE(code));
7474
}
7575

76-
icu::UnicodeString icu_string(StringView string);
77-
icu::StringPiece icu_string_piece(StringView string);
76+
ALWAYS_INLINE icu::StringPiece icu_string_piece(StringView string)
77+
{
78+
return { string.characters_without_null_termination(), static_cast<i32>(string.length()) };
79+
}
80+
81+
ALWAYS_INLINE icu::UnicodeString icu_string(StringView string)
82+
{
83+
return icu::UnicodeString::fromUTF8(icu_string_piece(string));
84+
}
7885

7986
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings);
8087

0 commit comments

Comments
 (0)