Backed out changeset 2d9717f5ca10 (bug 1858068) for causing bustage on Segmenter.cpp. CLOSED TREE

This commit is contained in:
Natalia Csoregi 2023-10-13 12:15:55 +03:00
Родитель 898f7acfcc
Коммит ec862c541a
2 изменённых файлов: 9 добавлений и 26 удалений

Просмотреть файл

@ -21,7 +21,6 @@
# include "ICU4XLineSegmenter.h"
# include "ICU4XSentenceSegmenter.h"
# include "ICU4XWordSegmenter.h"
# include "mozilla/ClearOnShutdown.h"
# include "mozilla/intl/ICU4XGeckoDataProvider.h"
#endif
@ -188,11 +187,6 @@ Maybe<uint32_t> WordBreakIteratorUtf16::Seek(uint32_t aPos) {
return SegmentIteratorUtf16::Seek(aPos);
}
#if defined(MOZ_ICU4X) && defined(JS_HAS_INTL_API)
capi::ICU4XGraphemeClusterSegmenter*
GraphemeClusterBreakIteratorUtf16::sSegmenter = nullptr;
#endif
GraphemeClusterBreakIteratorUtf16::GraphemeClusterBreakIteratorUtf16(
Span<const char16_t> aText)
: SegmentIteratorUtf16(aText) {
@ -200,26 +194,12 @@ GraphemeClusterBreakIteratorUtf16::GraphemeClusterBreakIteratorUtf16(
if (!StaticPrefs::intl_icu4x_segmenter_enabled()) {
return;
}
static std::once_flag sOnce;
std::call_once(sOnce, [] {
auto result = capi::ICU4XGraphemeClusterSegmenter_create(
mozilla::intl::GetDataProvider());
MOZ_RELEASE_ASSERT(result.is_ok);
sSegmenter = result.ok;
NS_DispatchToMainThread(
NS_NewRunnableFunction("GraphemeClusterBreakIteratorUtf16", [] {
RunOnShutdown([] {
capi::ICU4XGraphemeClusterSegmenter_destroy(sSegmenter);
sSegmenter = nullptr;
});
}));
});
MOZ_RELEASE_ASSERT(sSegmenter);
auto result = capi::ICU4XGraphemeClusterSegmenter_create(
mozilla::intl::GetDataProvider());
MOZ_RELEASE_ASSERT(result.is_ok);
mSegmenter = result.ok;
mIterator = capi::ICU4XGraphemeClusterSegmenter_segment_utf16(
sSegmenter, (const uint16_t*)mText.Elements(), mText.Length());
mSegmenter, (const uint16_t*)mText.Elements(), mText.Length());
#endif
}
@ -228,6 +208,9 @@ GraphemeClusterBreakIteratorUtf16::~GraphemeClusterBreakIteratorUtf16() {
if (mIterator) {
capi::ICU4XGraphemeClusterBreakIteratorUtf16_destroy(mIterator);
}
if (mSegmenter) {
capi::ICU4XGraphemeClusterSegmenter_destroy(mSegmenter);
}
#endif
}

Просмотреть файл

@ -162,7 +162,7 @@ class GraphemeClusterBreakIteratorUtf16 final : public SegmentIteratorUtf16 {
#if defined(MOZ_ICU4X) && defined(JS_HAS_INTL_API)
private:
static capi::ICU4XGraphemeClusterSegmenter* sSegmenter;
capi::ICU4XGraphemeClusterSegmenter* mSegmenter = nullptr;
capi::ICU4XGraphemeClusterBreakIteratorUtf16* mIterator = nullptr;
#endif
};