| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "wtf/text/StringConcatenate.h" | 7 #include "wtf/text/StringConcatenate.h" |
| 8 | 8 |
| 9 // This macro is helpful for testing how many intermediate Strings are created w
hile evaluating an | 9 // This macro is helpful for testing how many intermediate Strings are created w
hile evaluating an |
| 10 // expression containing operator+. | 10 // expression containing operator+. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 for (size_t i = 0; i < m_buffer.size(); ++i) | 111 for (size_t i = 0; i < m_buffer.size(); ++i) |
| 112 destination[i] = m_buffer[i]; | 112 destination[i] = m_buffer[i]; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WTF::StringTypeAdapter<Vector<LChar>>::writeTo(UChar* destination) | 115 void WTF::StringTypeAdapter<Vector<LChar>>::writeTo(UChar* destination) |
| 116 { | 116 { |
| 117 for (size_t i = 0; i < m_buffer.size(); ++i) | 117 for (size_t i = 0; i < m_buffer.size(); ++i) |
| 118 destination[i] = m_buffer[i]; | 118 destination[i] = m_buffer[i]; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void WTF::StringTypeAdapter<String>::writeTo(LChar* destination) | 121 void WTF::StringTypeAdapter<StringView>::writeTo(LChar* destination) |
| 122 { | 122 { |
| 123 unsigned length = m_buffer.length(); | 123 DCHECK(is8Bit()); |
| 124 | 124 StringImpl::copyChars(destination, m_view.characters8(), m_view.length()); |
| 125 ASSERT(is8Bit()); | |
| 126 const LChar* data = m_buffer.characters8(); | |
| 127 for (unsigned i = 0; i < length; ++i) | |
| 128 destination[i] = data[i]; | |
| 129 | |
| 130 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); | 125 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); |
| 131 } | 126 } |
| 132 | 127 |
| 133 void WTF::StringTypeAdapter<String>::writeTo(UChar* destination) | 128 void WTF::StringTypeAdapter<StringView>::writeTo(UChar* destination) |
| 134 { | 129 { |
| 135 unsigned length = m_buffer.length(); | 130 if (is8Bit()) |
| 136 | 131 StringImpl::copyChars(destination, m_view.characters8(), m_view.length()
); |
| 137 if (is8Bit()) { | 132 else |
| 138 const LChar* data = m_buffer.characters8(); | 133 StringImpl::copyChars(destination, m_view.characters16(), m_view.length(
)); |
| 139 for (unsigned i = 0; i < length; ++i) | |
| 140 destination[i] = data[i]; | |
| 141 } else { | |
| 142 const UChar* data = m_buffer.characters16(); | |
| 143 for (unsigned i = 0; i < length; ++i) | |
| 144 destination[i] = data[i]; | |
| 145 } | |
| 146 | |
| 147 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); | 134 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); |
| 148 } | 135 } |
| 149 | |
| OLD | NEW |