Changeset 53454 in webkit for trunk/JavaScriptCore/runtime/UStringImpl.cpp
- Timestamp:
- Jan 18, 2010, 9:51:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UStringImpl.cpp
r53400 r53454 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 49 38 SharedUChar* UStringImpl::sharedBuffer() 50 39 { 51 if (m_length < s_minLengthToShare) 52 return 0; 53 ASSERT(!isStatic()); 54 55 UStringImpl* owner = bufferOwnerString(); 56 if (owner->bufferOwnership() == BufferInternal) 40 if (m_length < s_minLengthToShare || isStatic()) 57 41 return 0; 58 42 59 return owner->baseSharedBuffer(); 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; 60 59 } 61 60 … … 63 62 { 64 63 ASSERT(!isStatic()); 65 checkConsistency();66 64 67 65 if (isIdentifier()) 68 66 Identifier::remove(this); 69 67 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 } 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(); 79 79 } 80 80 } 81 81 82 } 82 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.