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

Unified Diff: src/inspector/string-16.cc

Issue 2493723003: [inspector] Fix and refactor String16 (Closed)
Patch Set: Windows unhappy; revert last patch and define move assignment manually Created 4 years, 1 month 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: src/inspector/string-16.cc
diff --git a/src/inspector/string-16.cc b/src/inspector/string-16.cc
index ddccc09385c737e333c75975ff00644d95ae3116..09909a911bb158784ba3159e3bcc287a3445b85f 100644
--- a/src/inspector/string-16.cc
+++ b/src/inspector/string-16.cc
@@ -447,6 +447,26 @@ void String16Builder::append(const char* characters, size_t length) {
m_buffer.insert(m_buffer.end(), characters, characters + length);
}
+void String16Builder::appendNumber(int number) {
+ const int kBufferSize = 11;
+ char buffer[kBufferSize];
+ int chars = v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number);
+ DCHECK_GT(kBufferSize, chars);
+ m_buffer.insert(m_buffer.end(), buffer, buffer + chars);
+}
+
+void String16Builder::appendNumber(size_t number) {
+ const int kBufferSize = 20;
+ char buffer[kBufferSize];
+#if !defined(_WIN32) && !defined(_WIN64)
+ int chars = v8::base::OS::SNPrintF(buffer, kBufferSize, "%zu", number);
+#else
+ int chars = v8::base::OS::SNPrintF(buffer, kBufferSize, "%Iu", number);
+#endif
+ DCHECK_GT(kBufferSize, chars);
+ m_buffer.insert(m_buffer.end(), buffer, buffer + chars);
+}
+
String16 String16Builder::toString() {
return String16(m_buffer.data(), m_buffer.size());
}

Powered by Google App Engine
This is Rietveld 408576698