Changeset 123504 in webkit
- Timestamp:
- Jul 24, 2012, 12:12:42 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r123500 r123504 1 2012-07-24 Benjamin Poulain <bpoulain@apple.com> 2 3 Do not perform 8 to 16bits characters conversion when converting a WTFString to NSString/CFString 4 https://bugs.webkit.org/show_bug.cgi?id=90720 5 6 Reviewed by Geoffrey Garen. 7 8 In most String to CFString conversion, we should be able to use the "NoCopy" constructor and have 9 a relatively cheap conversion from WTF::String to CFString. 10 11 When the String is 8 bits, it was converted to 16 bits by getData16SlowCase() because of the call 12 to String::characters(). 13 14 This patch adds a path for creating a CFString from a 8bits string using CFStringCreateWithBytes. 15 16 This is covered by existing tests. 17 18 * platform/text/cf/StringCF.cpp: 19 (WTF::String::createCFString): CFSTR() create static CFString, it is unecessary to retain it. 20 * platform/text/cf/StringImplCF.cpp: 21 (WTF::StringImpl::createCFString): The logic to avoid the StringWrapperCFAllocator has also been simplified. 22 The allocator creation is now closer to where it is useful. 23 1 24 2012-07-24 Kentaro Hara <haraken@chromium.org> 2 25 -
trunk/Source/WebCore/platform/text/cf/StringCF.cpp
r79434 r123504 46 46 { 47 47 if (!m_impl) 48 return static_cast<CFStringRef>(CFRetain(CFSTR("")));48 return CFSTR(""); 49 49 50 50 return m_impl->createCFString(); -
trunk/Source/WebCore/platform/text/cf/StringImplCF.cpp
r98624 r123504 135 135 CFStringRef StringImpl::createCFString() 136 136 { 137 CFAllocatorRef allocator = (m_length && isMainThread()) ? StringWrapperCFAllocator::allocator() : 0; 138 if (!allocator) 139 return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(characters()), m_length); 137 if (!m_length || !isMainThread()) { 138 if (is8Bit()) 139 return CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false); 140 return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(characters16()), m_length); 141 } 142 CFAllocatorRef allocator = StringWrapperCFAllocator::allocator(); 140 143 141 144 // Put pointer to the StringImpl in a global so the allocator can store it with the CFString. … … 143 146 StringWrapperCFAllocator::currentString = this; 144 147 145 CFStringRef string = CFStringCreateWithCharactersNoCopy(allocator, reinterpret_cast<const UniChar*>(characters()), m_length, kCFAllocatorNull); 148 CFStringRef string; 149 if (is8Bit()) 150 string = CFStringCreateWithBytesNoCopy(allocator, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false, kCFAllocatorNull); 151 else 152 string = CFStringCreateWithCharactersNoCopy(allocator, reinterpret_cast<const UniChar*>(characters16()), m_length, kCFAllocatorNull); 146 153 147 154 // The allocator cleared the global when it read it, but also clear it here just in case.
Note:
See TracChangeset
for help on using the changeset viewer.