@@ -121,11 +121,9 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
121
121
122
122
// If there is a result, set the valid locale and actual locale, and the kind
123
123
if (U_SUCCESS (status) && result != nullptr ) {
124
- U_LOCALE_BASED (locBased, *(BreakIterator*)result);
125
-
126
- locBased.setLocaleIDs (ures_getLocaleByType (b, ULOC_VALID_LOCALE, &status),
127
- actual.data (), status);
128
- LocaleBased::setLocaleID (loc.getName (), result->requestLocale , status);
124
+ result->actualLocale = Locale (actual.data ());
125
+ result->validLocale = Locale (ures_getLocaleByType (b, ULOC_VALID_LOCALE, &status));
126
+ result->requestLocale = loc;
129
127
}
130
128
131
129
ures_close (b);
@@ -204,33 +202,28 @@ BreakIterator::getAvailableLocales(int32_t& count)
204
202
// -------------------------------------------
205
203
206
204
BreakIterator::BreakIterator ()
205
+ : actualLocale(Locale::getRoot()), validLocale(Locale::getRoot()), requestLocale(Locale::getRoot())
207
206
{
208
207
}
209
208
210
- BreakIterator::BreakIterator (const BreakIterator &other) : UObject(other) {
211
- UErrorCode status = U_ZERO_ERROR;
212
- U_LOCALE_BASED (locBased, *this );
213
- locBased.setLocaleIDs (other.validLocale , other.actualLocale , status);
214
- LocaleBased::setLocaleID (other.requestLocale , requestLocale, status);
215
- U_ASSERT (U_SUCCESS (status));
209
+ BreakIterator::BreakIterator (const BreakIterator &other)
210
+ : UObject(other),
211
+ actualLocale(other.actualLocale),
212
+ validLocale(other.validLocale),
213
+ requestLocale(other.requestLocale) {
216
214
}
217
215
218
216
BreakIterator &BreakIterator::operator =(const BreakIterator &other) {
219
217
if (this != &other) {
220
- UErrorCode status = U_ZERO_ERROR;
221
- U_LOCALE_BASED (locBased, *this );
222
- locBased.setLocaleIDs (other.validLocale , other.actualLocale , status);
223
- LocaleBased::setLocaleID (other.requestLocale , requestLocale, status);
224
- U_ASSERT (U_SUCCESS (status));
218
+ actualLocale = other.actualLocale ;
219
+ validLocale = other.validLocale ;
220
+ requestLocale = other.requestLocale ;
225
221
}
226
222
return *this ;
227
223
}
228
224
229
225
BreakIterator::~BreakIterator ()
230
226
{
231
- delete validLocale;
232
- delete actualLocale;
233
- delete requestLocale;
234
227
}
235
228
236
229
// ------------------------------------------
@@ -398,8 +391,8 @@ BreakIterator::createInstance(const Locale& loc, int32_t kind, UErrorCode& statu
398
391
// THIS LONG is a sign of bad code -- so the action item is to
399
392
// revisit this in ICU 3.0 and clean it up/fix it/remove it.
400
393
if (U_SUCCESS (status) && (result != nullptr ) && *actualLoc.getName () != 0 ) {
401
- U_LOCALE_BASED (locBased, * result) ;
402
- locBased. setLocaleIDs (actualLoc. getName (), actualLoc. getName (), status) ;
394
+ result-> actualLocale = actualLoc ;
395
+ result-> validLocale = actualLoc ;
403
396
}
404
397
return result;
405
398
}
@@ -506,8 +499,7 @@ BreakIterator::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
506
499
return Locale::getRoot ();
507
500
}
508
501
if (type == ULOC_REQUESTED_LOCALE) {
509
- return requestLocale == nullptr ?
510
- Locale::getRoot () : Locale (requestLocale->data ());
502
+ return requestLocale;
511
503
}
512
504
return LocaleBased::getLocale (validLocale, actualLocale, type, status);
513
505
}
@@ -518,7 +510,7 @@ BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
518
510
return nullptr ;
519
511
}
520
512
if (type == ULOC_REQUESTED_LOCALE) {
521
- return requestLocale == nullptr ? " " : requestLocale-> data ();
513
+ return requestLocale. getName ();
522
514
}
523
515
return LocaleBased::getLocaleID (validLocale, actualLocale, type, status);
524
516
}
@@ -546,11 +538,8 @@ int32_t BreakIterator::getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UE
546
538
return 1 ;
547
539
}
548
540
549
- BreakIterator::BreakIterator (const Locale& valid, const Locale& actual) {
550
- UErrorCode status = U_ZERO_ERROR;
551
- U_LOCALE_BASED (locBased, (*this ));
552
- locBased.setLocaleIDs (valid.getName (), actual.getName (), status);
553
- U_ASSERT (U_SUCCESS (status));
541
+ BreakIterator::BreakIterator (const Locale& valid, const Locale& actual)
542
+ : actualLocale(actual), validLocale(valid), requestLocale(Locale::getRoot()) {
554
543
}
555
544
556
545
U_NAMESPACE_END
0 commit comments