Changeset 53456 in webkit for trunk/JavaScriptCore/runtime/UStringImpl.cpp
- Timestamp:
- Jan 18, 2010, 11:22:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UStringImpl.cpp
r53454 r53456 36 36 namespace JSC { 37 37 38 SharedUChar* UStringImpl::baseSharedBuffer() 39 { 40 ASSERT((bufferOwnership() == BufferShared) 41 || ((bufferOwnership() == BufferOwned) && !m_dataBuffer.asPtr<void*>())); 42 43 if (bufferOwnership() != BufferShared) 44 m_dataBuffer = UntypedPtrAndBitfield(SharedUChar::create(new OwnFastMallocPtr<UChar>(m_data)).releaseRef(), BufferShared); 45 46 return m_dataBuffer.asPtr<SharedUChar*>(); 47 } 48 38 49 SharedUChar* UStringImpl::sharedBuffer() 39 50 { 40 if (m_length < s_minLengthToShare || isStatic()) 51 if (m_length < s_minLengthToShare) 52 return 0; 53 ASSERT(!isStatic()); 54 55 UStringImpl* owner = bufferOwnerString(); 56 if (owner->bufferOwnership() == BufferInternal) 41 57 return 0; 42 58 43 switch (bufferOwnership()) { 44 case BufferInternal: 45 return 0; 46 case BufferOwned: 47 m_bufferShared = SharedUChar::create(new OwnFastMallocPtr<UChar>(m_data)).releaseRef(); 48 m_refCountAndFlags &= ~s_refCountMaskBufferOwnership; 49 m_refCountAndFlags |= BufferShared; 50 return m_bufferShared; 51 case BufferSubstring: 52 return m_bufferSubstring->sharedBuffer(); 53 case BufferShared: 54 return m_bufferShared; 55 } 56 57 ASSERT_NOT_REACHED(); 58 return 0; 59 return owner->baseSharedBuffer(); 59 60 } 60 61 … … 62 63 { 63 64 ASSERT(!isStatic()); 65 checkConsistency(); 64 66 65 67 if (isIdentifier()) 66 68 Identifier::remove(this); 67 69 68 switch (bufferOwnership()) { 69 case BufferInternal: 70 return; 71 case BufferOwned: 72 fastFree(m_data); 73 return; 74 case BufferSubstring: 75 m_bufferSubstring->deref(); 76 return; 77 case BufferShared: 78 m_bufferSubstring->deref(); 70 if (bufferOwnership() != BufferInternal) { 71 if (bufferOwnership() == BufferOwned) 72 fastFree(m_data); 73 else if (bufferOwnership() == BufferSubstring) 74 m_dataBuffer.asPtr<UStringImpl*>()->deref(); 75 else { 76 ASSERT(bufferOwnership() == BufferShared); 77 m_dataBuffer.asPtr<SharedUChar*>()->deref(); 78 } 79 79 } 80 80 } 81 81 82 } // namespace JSC82 }
Note:
See TracChangeset
for help on using the changeset viewer.