DigitList& DigitList::operator=(const DigitList& other) { if (this != &other) { uprv_memcpy(&fContext, &other.fContext, sizeof(decContext)); if (other.fStorage.getCapacity() > fStorage.getCapacity()) { fDecNumber = fStorage.resize(other.fStorage.getCapacity()); } // Always reset the fContext.digits, even if fDecNumber was not reallocated, // because above we copied fContext from other.fContext. fContext.digits = fStorage.getCapacity(); uprv_decNumberCopy(fDecNumber, other.fDecNumber); { // fDouble is lazily created and cached. // Avoid potential races with that happening with other.fDouble // while we are doing the assignment. Mutex mutex; if(other.fHave==kDouble) { fUnion.fDouble = other.fUnion.fDouble; } fHave = other.fHave; } } return *this; }
DigitList& DigitList::operator=(const DigitList& other) { if (this != &other) { uprv_memcpy(&fContext, &other.fContext, sizeof(decContext)); fStorage.resize(other.fStorage.getCapacity()); fDecNumber = (decNumber *)fStorage.getAlias(); uprv_decNumberCopy(fDecNumber, other.fDecNumber); fDouble = other.fDouble; fHaveDouble = other.fHaveDouble; } return *this; }
DigitList& DigitList::operator=(const DigitList& other) { if (this != &other) { uprv_memcpy(&fContext, &other.fContext, sizeof(decContext)); if (other.fStorage.getCapacity() > fStorage.getCapacity()) { fDecNumber = fStorage.resize(other.fStorage.getCapacity()); } // Always reset the fContext.digits, even if fDecNumber was not reallocated, // because above we copied fContext from other.fContext. fContext.digits = fStorage.getCapacity(); uprv_decNumberCopy(fDecNumber, other.fDecNumber); fDouble = other.fDouble; fHaveDouble = other.fHaveDouble; } return *this; }