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

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

Issue 2956603002: Add StringBuilder::erase(index) (Closed)
Patch Set: StringBuilder.erase Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp
diff --git a/third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp b/third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp
index 0e112bea782c58d0821612e139e5dd6ceae1320b..91c3e5c172ca8feaa5e54b8a2c3955bec13dacec 100644
--- a/third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp
+++ b/third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp
@@ -230,4 +230,20 @@ void StringBuilder::AppendNumber(double number, unsigned precision) {
Append(NumberToFixedPrecisionString(number, precision, buffer));
}
+void StringBuilder::erase(unsigned index) {
+ if (index >= length_)
+ return;
+ if (index == length_ - 1)
+ return Resize(index);
+
+ if (is8_bit_) {
+ 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
+ buffer8_->erase(index);
+ } else {
+ EnsureBuffer16(0);
haraken 2017/06/23 13:16:49 Ditto.
+ buffer16_->erase(index);
+ }
+ --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.
+}
+
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698