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

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

Issue 2956603002: Add StringBuilder::erase(index) (Closed)
Patch Set: StringBuilder.erase Created 3 years, 5 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
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 void StringBuilder::AppendNumber(unsigned long long number) { 224 void StringBuilder::AppendNumber(unsigned long long number) {
225 AppendIntegerInternal(*this, number); 225 AppendIntegerInternal(*this, number);
226 } 226 }
227 227
228 void StringBuilder::AppendNumber(double number, unsigned precision) { 228 void StringBuilder::AppendNumber(double number, unsigned precision) {
229 NumberToStringBuffer buffer; 229 NumberToStringBuffer buffer;
230 Append(NumberToFixedPrecisionString(number, precision, buffer)); 230 Append(NumberToFixedPrecisionString(number, precision, buffer));
231 } 231 }
232 232
233 void StringBuilder::erase(unsigned index) {
234 if (index >= length_)
235 return;
236 if (index == length_ - 1)
237 return Resize(index);
238
239 if (is8_bit_) {
240 EnsureBuffer8(0);
haraken 2017/06/23 13:16:49 Do you need this?
kojii 2017/06/23 13:45:23 Yes, since StringBuilder may have StringImpl but n
241 buffer8_->erase(index);
242 } else {
243 EnsureBuffer16(0);
haraken 2017/06/23 13:16:49 Ditto.
244 buffer16_->erase(index);
245 }
246 --length_;
haraken 2017/06/23 13:16:49 Do you want to call Resize() in this case as well?
kojii 2017/06/23 13:45:23 I guess you misunderstood something, probably due
haraken 2017/06/23 13:56:17 Makes sense. Yeah, remove it or add a comment.
kojii 2017/06/23 14:04:21 Thank you for prompt reply, removed.
247 }
248
233 } // namespace WTF 249 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698