OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 append(string.characters16(), string.length()); | 109 append(string.characters16(), string.length()); |
110 } | 110 } |
111 | 111 |
112 void append(UChar c) | 112 void append(UChar c) |
113 { | 113 { |
114 if (m_is8Bit && c <= 0xFF) { | 114 if (m_is8Bit && c <= 0xFF) { |
115 append(static_cast<LChar>(c)); | 115 append(static_cast<LChar>(c)); |
116 return; | 116 return; |
117 } | 117 } |
118 ensureBuffer16(1); | 118 ensureBuffer16(1); |
119 m_string = String(); | |
120 m_buffer16->append(c); | 119 m_buffer16->append(c); |
121 ++m_length; | 120 ++m_length; |
122 } | 121 } |
123 | 122 |
124 void append(LChar c) | 123 void append(LChar c) |
125 { | 124 { |
126 if (!m_is8Bit) { | 125 if (!m_is8Bit) { |
127 append(static_cast<UChar>(c)); | 126 append(static_cast<UChar>(c)); |
128 return; | 127 return; |
129 } | 128 } |
130 ensureBuffer8(1); | 129 ensureBuffer8(1); |
131 m_string = String(); | |
132 m_buffer8->append(c); | 130 m_buffer8->append(c); |
133 ++m_length; | 131 ++m_length; |
134 } | 132 } |
135 | 133 |
136 void append(char c) | 134 void append(char c) |
137 { | 135 { |
138 append(static_cast<LChar>(c)); | 136 append(static_cast<LChar>(c)); |
139 } | 137 } |
140 | 138 |
141 void append(UChar32 c) | 139 void append(UChar32 c) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 217 } |
220 | 218 |
221 void ensureBuffer16(unsigned addedSize) | 219 void ensureBuffer16(unsigned addedSize) |
222 { | 220 { |
223 if (m_is8Bit || !hasBuffer()) | 221 if (m_is8Bit || !hasBuffer()) |
224 createBuffer16(addedSize); | 222 createBuffer16(addedSize); |
225 } | 223 } |
226 | 224 |
227 void createBuffer8(unsigned addedSize); | 225 void createBuffer8(unsigned addedSize); |
228 void createBuffer16(unsigned addedSize); | 226 void createBuffer16(unsigned addedSize); |
229 | 227 void clearBuffer(); |
230 bool hasBuffer() const { return m_buffer; } | 228 bool hasBuffer() const { return m_buffer; } |
231 | 229 |
232 String m_string; | 230 String m_string; |
233 union { | 231 union { |
234 Buffer8* m_buffer8; | 232 Buffer8* m_buffer8; |
235 Buffer16* m_buffer16; | 233 Buffer16* m_buffer16; |
236 void* m_buffer; | 234 void* m_buffer; |
237 }; | 235 }; |
238 unsigned m_length; | 236 unsigned m_length; |
239 bool m_is8Bit; | 237 bool m_is8Bit; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 inline bool operator==(const StringBuilder& a, const String& b) { return equal(a
, b); } | 311 inline bool operator==(const StringBuilder& a, const String& b) { return equal(a
, b); } |
314 inline bool operator!=(const StringBuilder& a, const String& b) { return !equal(
a, b); } | 312 inline bool operator!=(const StringBuilder& a, const String& b) { return !equal(
a, b); } |
315 inline bool operator==(const String& a, const StringBuilder& b) { return equal(b
, a); } | 313 inline bool operator==(const String& a, const StringBuilder& b) { return equal(b
, a); } |
316 inline bool operator!=(const String& a, const StringBuilder& b) { return !equal(
b, a); } | 314 inline bool operator!=(const String& a, const StringBuilder& b) { return !equal(
b, a); } |
317 | 315 |
318 } // namespace WTF | 316 } // namespace WTF |
319 | 317 |
320 using WTF::StringBuilder; | 318 using WTF::StringBuilder; |
321 | 319 |
322 #endif // StringBuilder_h | 320 #endif // StringBuilder_h |
OLD | NEW |