| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
reserved. |
| 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (isNull()) | 224 if (isNull()) |
| 225 return; | 225 return; |
| 226 if (!is8Bit()) | 226 if (!is8Bit()) |
| 227 return; | 227 return; |
| 228 if (unsigned length = this->length()) | 228 if (unsigned length = this->length()) |
| 229 m_impl = make16BitFrom8BitSource(m_impl->characters8(), length).releaseI
mpl(); | 229 m_impl = make16BitFrom8BitSource(m_impl->characters8(), length).releaseI
mpl(); |
| 230 else | 230 else |
| 231 m_impl = StringImpl::empty16Bit(); | 231 m_impl = StringImpl::empty16Bit(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void String::truncate(unsigned position) | 234 void String::truncate(unsigned length) |
| 235 { | 235 { |
| 236 if (position >= length()) | 236 if (m_impl) |
| 237 return; | 237 m_impl = m_impl->truncate(length); |
| 238 if (m_impl->is8Bit()) { | |
| 239 LChar* data; | |
| 240 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(position, d
ata); | |
| 241 memcpy(data, m_impl->characters8(), position * sizeof(LChar)); | |
| 242 m_impl = newImpl.release(); | |
| 243 } else { | |
| 244 UChar* data; | |
| 245 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(position, d
ata); | |
| 246 memcpy(data, m_impl->characters16(), position * sizeof(UChar)); | |
| 247 m_impl = newImpl.release(); | |
| 248 } | |
| 249 } | 238 } |
| 250 | 239 |
| 251 void String::remove(unsigned start, unsigned lengthToRemove) | 240 void String::remove(unsigned start, unsigned lengthToRemove) |
| 252 { | 241 { |
| 253 if (m_impl) | 242 if (m_impl) |
| 254 m_impl = m_impl->remove(start, lengthToRemove); | 243 m_impl = m_impl->remove(start, lengthToRemove); |
| 255 } | 244 } |
| 256 | 245 |
| 257 String String::substring(unsigned pos, unsigned len) const | 246 String String::substring(unsigned pos, unsigned len) const |
| 258 { | 247 { |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 buffer.append('\0'); | 877 buffer.append('\0'); |
| 889 return buffer; | 878 return buffer; |
| 890 } | 879 } |
| 891 | 880 |
| 892 Vector<char> asciiDebug(String& string) | 881 Vector<char> asciiDebug(String& string) |
| 893 { | 882 { |
| 894 return asciiDebug(string.impl()); | 883 return asciiDebug(string.impl()); |
| 895 } | 884 } |
| 896 | 885 |
| 897 #endif | 886 #endif |
| OLD | NEW |