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

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

Issue 2192293002: StringBuilder::append should not use reserveCapacity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (m_is8Bit) { 193 if (m_is8Bit) {
194 ensureBuffer8(length); 194 ensureBuffer8(length);
195 m_string = String(); 195 m_string = String();
196 m_buffer8->append(characters, length); 196 m_buffer8->append(characters, length);
197 m_length += length; 197 m_length += length;
198 return; 198 return;
199 } 199 }
200 200
201 ensureBuffer16(length); 201 ensureBuffer16(length);
202 m_string = String(); 202 m_string = String();
203 m_buffer16->reserveCapacity(m_buffer16->size() + length); 203 m_buffer16->append(characters, length);
204 for (size_t i = 0; i < length; ++i)
205 m_buffer16->uncheckedAppend(characters[i]);
206 m_length += length; 204 m_length += length;
207 } 205 }
208 206
209 template<typename IntegerType> 207 template<typename IntegerType>
210 static void appendIntegerInternal(StringBuilder& builder, IntegerType input) 208 static void appendIntegerInternal(StringBuilder& builder, IntegerType input)
211 { 209 {
212 IntegerToStringConverter<IntegerType> converter(input); 210 IntegerToStringConverter<IntegerType> converter(input);
213 builder.append(converter.characters8(), converter.length()); 211 builder.append(converter.characters8(), converter.length());
214 } 212 }
215 213
(...skipping 27 matching lines...) Expand all
243 appendIntegerInternal(*this, number); 241 appendIntegerInternal(*this, number);
244 } 242 }
245 243
246 void StringBuilder::appendNumber(double number, unsigned precision, TrailingZero sTruncatingPolicy trailingZerosTruncatingPolicy) 244 void StringBuilder::appendNumber(double number, unsigned precision, TrailingZero sTruncatingPolicy trailingZerosTruncatingPolicy)
247 { 245 {
248 NumberToStringBuffer buffer; 246 NumberToStringBuffer buffer;
249 append(numberToFixedPrecisionString(number, precision, buffer, trailingZeros TruncatingPolicy == TruncateTrailingZeros)); 247 append(numberToFixedPrecisionString(number, precision, buffer, trailingZeros TruncatingPolicy == TruncateTrailingZeros));
250 } 248 }
251 249
252 } // namespace WTF 250 } // 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