OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2009, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 CFAllocatorContext context = { 0, 0, retain, release, copyDescription, alloc
ate, reallocate, deallocate, preferredSize }; | 115 CFAllocatorContext context = { 0, 0, retain, release, copyDescription, alloc
ate, reallocate, deallocate, preferredSize }; |
116 return CFAllocatorCreate(0, &context); | 116 return CFAllocatorCreate(0, &context); |
117 } | 117 } |
118 | 118 |
119 static CFAllocatorRef allocator() | 119 static CFAllocatorRef allocator() |
120 { | 120 { |
121 static CFAllocatorRef allocator = create(); | 121 static CFAllocatorRef allocator = create(); |
122 return allocator; | 122 return allocator; |
123 } | 123 } |
124 | 124 |
125 } | 125 } // namespace StringWrapperCFAllocator |
126 | 126 |
127 RetainPtr<CFStringRef> StringImpl::createCFString() | 127 RetainPtr<CFStringRef> StringImpl::createCFString() |
128 { | 128 { |
129 // Since garbage collection isn't compatible with custom allocators, we | 129 // Since garbage collection isn't compatible with custom allocators, we |
130 // can't use the NoCopy variants of CFStringCreate*() when GC is enabled. | 130 // can't use the NoCopy variants of CFStringCreate*() when GC is enabled. |
131 if (!m_length || !isMainThread()) { | 131 if (!m_length || !isMainThread()) { |
132 if (is8Bit()) | 132 if (is8Bit()) |
133 return adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UIn
t8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false)); | 133 return adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UIn
t8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false)); |
134 return adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const Un
iChar*>(characters16()), m_length)); | 134 return adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const Un
iChar*>(characters16()), m_length)); |
135 } | 135 } |
(...skipping 14 matching lines...) Expand all Loading... |
150 return adoptCF(string); | 150 return adoptCF(string); |
151 } | 151 } |
152 | 152 |
153 // On StringImpl creation we could check if the allocator is the StringWrapperCF
Allocator. | 153 // On StringImpl creation we could check if the allocator is the StringWrapperCF
Allocator. |
154 // If it is, then we could find the original StringImpl and just return that. Bu
t to | 154 // If it is, then we could find the original StringImpl and just return that. Bu
t to |
155 // do that we'd have to compute the offset from CFStringRef to the allocated blo
ck; | 155 // do that we'd have to compute the offset from CFStringRef to the allocated blo
ck; |
156 // the CFStringRef is *not* at the start of an allocated block. Testing shows 10
00x | 156 // the CFStringRef is *not* at the start of an allocated block. Testing shows 10
00x |
157 // more calls to createCFString than calls to the create functions with the appr
opriate | 157 // more calls to createCFString than calls to the create functions with the appr
opriate |
158 // allocator, so it's probably not urgent optimize that case. | 158 // allocator, so it's probably not urgent optimize that case. |
159 | 159 |
160 } | 160 } // namespace WTF |
161 | 161 |
162 #endif // OS(MACOSX) | 162 #endif // OS(MACOSX) |
OLD | NEW |