}
Edits &Edits::operator=(const Edits &other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
length = other.length;
delta = other.delta;
numChanges = other.numChanges;
CompoundTransliterator& CompoundTransliterator::operator=(
const CompoundTransliterator& t)
{
+ if (this == &t) { return *this; } // self-assignment: no-op
Transliterator::operator=(t);
int32_t i = 0;
UBool failed = FALSE;
*/
DateFormatSymbols& DateFormatSymbols::operator=(const DateFormatSymbols& other)
{
+ if (this == &other) { return *this; } // self-assignment: no-op
dispose();
copyData(other);
// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
// Using this wrapper is rather unfortunate, but is needed on Windows platforms in order to allow
-// for DLL-exporting an fully specified template instantiation.
+// for DLL-exporting a fully specified template instantiation.
class U_I18N_API CurrencyPluralInfoWrapper {
public:
LocalPointer<CurrencyPluralInfo> fPtr;
}
CurrencyPluralInfoWrapper& operator=(const CurrencyPluralInfoWrapper& other) {
- if (!other.fPtr.isNull()) {
+ if (this != &other && // self-assignment: no-op
+ !other.fPtr.isNull()) {
fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr));
}
return *this;
}
LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(const LNF& other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
NFS<LNF>::operator=(static_cast<const NFS<LNF>&>(other));
UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error
lnfCopyHelper(other, localStatus);
}
Scale& Scale::operator=(const Scale& other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
fMagnitude = other.fMagnitude;
if (other.fArbitrary != nullptr) {
UErrorCode localStatus = U_ZERO_ERROR;
// Copy assignment operator
StringProp &StringProp::operator=(const StringProp &other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
fLength = 0;
fError = other.fError;
if (fValue != nullptr) {
}
LocalizedNumberRangeFormatter& LocalizedNumberRangeFormatter::operator=(const LNF& other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
NFS<LNF>::operator=(static_cast<const NFS<LNF>&>(other));
// Do not steal; just clear
delete fAtomicFormatter.exchange(nullptr);
* Assignment operator
*/
OlsonTimeZone& OlsonTimeZone::operator=(const OlsonTimeZone& other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
canonicalID = other.canonicalID;
transitionTimesPre32 = other.transitionTimesPre32;
// operator overloading ---------------------------------------------
StringSearch & StringSearch::operator=(const StringSearch &that)
{
- if ((*this) != that) {
+ if (this != &that) {
UErrorCode status = U_ZERO_ERROR;
m_text_ = that.m_text_;
m_breakiterator_ = that.m_breakiterator_;
* Assignment operator.
*/
Transliterator& Transliterator::operator=(const Transliterator& other) {
+ if (this == &other) { return *this; } // self-assignment: no-op
ID = other.ID;
// NUL-terminate the ID string
ID.getTerminatedBuffer();
Win32DateFormat &Win32DateFormat::operator=(const Win32DateFormat &other)
{
+ if (this == &other) { return *this; } // self-assignment: no-op
// The following handles fCalendar
DateFormat::operator=(other);
Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other)
{
+ if (this == &other) { return *this; } // self-assignment: no-op
NumberFormat::operator=(other);
this->fCurrency = other.fCurrency;
.unit(MeasureUnit::forIdentifier("pow4-mile", status))
.unitWidth(UNUM_UNIT_WIDTH_FULL_NAME)
.locale("en-ZA");
+ lnf.operator=(lnf); // self-assignment should be a no-op
lnf.formatInt(1, status);
status.expectErrorAndReset(U_RESOURCE_TYPE_MISMATCH);
dataerrln("ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString)u_errorName(status));
return;
}
+ symbol->operator=(*symbol); // self-assignment should be a no-op
int32_t cntFmtAbbrev, cntFmtShort, cntStdAloneShort;
const UnicodeString * wdFmtAbbrev = symbol->getWeekdays(cntFmtAbbrev,DateFormatSymbols::FORMAT,DateFormatSymbols::ABBREVIATED);
const UnicodeString * wdFmtShort = symbol->getWeekdays(cntFmtShort,DateFormatSymbols::FORMAT,DateFormatSymbols::SHORT);
TimeZone *zone = TimeZone::createTimeZone(id);
UnicodeString itsID, temp;
- if (dynamic_cast<OlsonTimeZone *>(zone) != NULL) {
+ OlsonTimeZone *ozone = dynamic_cast<OlsonTimeZone *>(zone);
+ if (ozone != nullptr) {
logln(id + " -> Olson time zone");
+ ozone->operator=(*ozone); // self-assignment should be a no-op
} else {
zone->getID(itsID);
int32_t ioffset = zone->getRawOffset()/1000;