OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 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 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "StringBuilder.h" | 28 #include "StringBuilder.h" |
29 | 29 |
30 #include "IntegerToStringConversion.h" | 30 #include "IntegerToStringConversion.h" |
31 #include "WTFString.h" | 31 #include "WTFString.h" |
32 #include "wtf/dtoa.h" | 32 #include "wtf/dtoa.h" |
| 33 #include <algorithm> |
33 | 34 |
34 namespace WTF { | 35 namespace WTF { |
35 | 36 |
36 static unsigned expandedCapacity(unsigned capacity, unsigned requiredLength) | 37 static unsigned expandedCapacity(unsigned capacity, unsigned requiredLength) |
37 { | 38 { |
38 static const unsigned minimumCapacity = 16; | 39 static const unsigned minimumCapacity = 16; |
39 return std::max(requiredLength, std::max(minimumCapacity, capacity * 2)); | 40 return std::max(requiredLength, std::max(minimumCapacity, capacity * 2)); |
40 } | 41 } |
41 | 42 |
42 void StringBuilder::reifyString() | 43 void StringBuilder::reifyString() |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (!canShrink()) | 377 if (!canShrink()) |
377 return; | 378 return; |
378 if (m_is8Bit) | 379 if (m_is8Bit) |
379 reallocateBuffer<LChar>(m_length); | 380 reallocateBuffer<LChar>(m_length); |
380 else | 381 else |
381 reallocateBuffer<UChar>(m_length); | 382 reallocateBuffer<UChar>(m_length); |
382 m_string = m_buffer.release(); | 383 m_string = m_buffer.release(); |
383 } | 384 } |
384 | 385 |
385 } // namespace WTF | 386 } // namespace WTF |
OLD | NEW |