ICU-10407 more efficient UnicodeString::refCount()
X-SVN-Rev: 34367
This commit is contained in:
parent
25bab8fa6f
commit
36663e1226
@ -117,23 +117,19 @@ operator+ (const UnicodeString &s1, const UnicodeString &s2) {
|
|||||||
//========================================
|
//========================================
|
||||||
|
|
||||||
void
|
void
|
||||||
UnicodeString::addRef()
|
UnicodeString::addRef() {
|
||||||
{ umtx_atomic_inc((u_atomic_int32_t *)fUnion.fFields.fArray - 1);}
|
umtx_atomic_inc((u_atomic_int32_t *)fUnion.fFields.fArray - 1);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
UnicodeString::removeRef()
|
UnicodeString::removeRef() {
|
||||||
{ return umtx_atomic_dec((u_atomic_int32_t *)fUnion.fFields.fArray - 1);}
|
return umtx_atomic_dec((u_atomic_int32_t *)fUnion.fFields.fArray - 1);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
UnicodeString::refCount() const
|
UnicodeString::refCount() const {
|
||||||
{
|
return umtx_loadAcquire(*((u_atomic_int32_t *)fUnion.fFields.fArray - 1));
|
||||||
umtx_lock(NULL);
|
}
|
||||||
// Note: without the lock to force a memory barrier, we might see a very
|
|
||||||
// stale value on some multi-processor systems.
|
|
||||||
int32_t count = *((int32_t *)fUnion.fFields.fArray - 1);
|
|
||||||
umtx_unlock(NULL);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UnicodeString::releaseArray() {
|
UnicodeString::releaseArray() {
|
||||||
|
Loading…
Reference in New Issue
Block a user