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

Unified Diff: src/counters.cc

Issue 2342643004: [Tracing] Remove unnecessary memory allocation in runtime call stats. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/counters.h ('k') | src/tracing/trace-event.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index 84568ac351fc696db2638d106f9d3b3fa02c9c41..c4e86460aa1140054a09f1f0abc0a1350e4054da 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -364,7 +364,7 @@ void RuntimeCallStats::Reset() {
in_use_ = true;
}
-const char* RuntimeCallStats::Dump() {
+std::string RuntimeCallStats::Dump() {
buffer_.str(std::string());
buffer_.clear();
buffer_ << "{";
@@ -393,15 +393,8 @@ const char* RuntimeCallStats::Dump() {
FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
#undef DUMP_COUNTER
buffer_ << "\"END\":[]}";
- const std::string& buffer_str = buffer_.str();
- size_t length = buffer_str.size();
- if (length > len_) {
- buffer_c_str_.reset(new char[length + 1]);
- len_ = length;
- }
- strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1);
in_use_ = false;
- return buffer_c_str_.get();
+ return buffer_.str();
}
} // namespace internal
« no previous file with comments | « src/counters.h ('k') | src/tracing/trace-event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698