Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringBuilder.cpp

Issue 2280723002: StringBuilder::append should not use reserveCapacity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (m_is8Bit) { 184 if (m_is8Bit) {
185 ensureBuffer8(); 185 ensureBuffer8();
186 m_string = String(); 186 m_string = String();
187 m_buffer8->append(characters, length); 187 m_buffer8->append(characters, length);
188 m_length += length; 188 m_length += length;
189 return; 189 return;
190 } 190 }
191 191
192 ensureBuffer16(); 192 ensureBuffer16();
193 m_string = String(); 193 m_string = String();
194 m_buffer16->reserveCapacity(m_buffer16->size() + length); 194 m_buffer16->append(characters, length);
195 for (size_t i = 0; i < length; ++i)
196 m_buffer16->uncheckedAppend(characters[i]);
197 m_length += length; 195 m_length += length;
198 } 196 }
199 197
200 template<typename IntegerType> 198 template<typename IntegerType>
201 static void appendIntegerInternal(StringBuilder& builder, IntegerType input) 199 static void appendIntegerInternal(StringBuilder& builder, IntegerType input)
202 { 200 {
203 IntegerToStringConverter<IntegerType> converter(input); 201 IntegerToStringConverter<IntegerType> converter(input);
204 builder.append(converter.characters8(), converter.length()); 202 builder.append(converter.characters8(), converter.length());
205 } 203 }
206 204
(...skipping 27 matching lines...) Expand all
234 appendIntegerInternal(*this, number); 232 appendIntegerInternal(*this, number);
235 } 233 }
236 234
237 void StringBuilder::appendNumber(double number, unsigned precision, TrailingZero sTruncatingPolicy trailingZerosTruncatingPolicy) 235 void StringBuilder::appendNumber(double number, unsigned precision, TrailingZero sTruncatingPolicy trailingZerosTruncatingPolicy)
238 { 236 {
239 NumberToStringBuffer buffer; 237 NumberToStringBuffer buffer;
240 append(numberToFixedPrecisionString(number, precision, buffer, trailingZeros TruncatingPolicy == TruncateTrailingZeros)); 238 append(numberToFixedPrecisionString(number, precision, buffer, trailingZeros TruncatingPolicy == TruncateTrailingZeros));
241 } 239 }
242 240
243 } // namespace WTF 241 } // namespace WTF
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698