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

Unified Diff: src/log.cc

Issue 334763003: Start using OStreams. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Reformatted. Feedback addressed. Created 6 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
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 6d88a535dc78f4ce10ce7a578d56d1b7b32b4e7c..ae5d37a8027366d1f19453b81c1b5627518b9044 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1972,16 +1972,15 @@ void Logger::LogAccessorCallbacks() {
}
-static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) {
- if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate);
+static void AddIsolateIdIfNeeded(OStream& os, // NOLINT
+ Isolate* isolate) {
+ if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-";
}
-static SmartArrayPointer<const char> PrepareLogFileName(
- Isolate* isolate, const char* file_name) {
- HeapStringAllocator allocator;
- StringStream stream(&allocator);
- AddIsolateIdIfNeeded(isolate, &stream);
+static void PrepareLogFileName(OStream& os, // NOLINT
+ Isolate* isolate, const char* file_name) {
+ AddIsolateIdIfNeeded(os, isolate);
for (const char* p = file_name; *p; p++) {
if (*p == '%') {
p++;
@@ -1992,29 +1991,25 @@ static SmartArrayPointer<const char> PrepareLogFileName(
p--;
break;
case 'p':
- stream.Add("%d", base::OS::GetCurrentProcessId());
+ os << base::OS::GetCurrentProcessId();
break;
- case 't': {
+ case 't':
// %t expands to the current time in milliseconds.
- double time = base::OS::TimeCurrentMillis();
- stream.Add("%.0f", FmtElm(time));
+ os << static_cast<int64_t>(base::OS::TimeCurrentMillis());
break;
- }
case '%':
// %% expands (contracts really) to %.
- stream.Put('%');
+ os << '%';
break;
default:
// All other %'s expand to themselves.
- stream.Put('%');
- stream.Put(*p);
+ os << '%' << *p;
break;
}
} else {
- stream.Put(*p);
+ os << *p;
}
}
- return SmartArrayPointer<const char>(stream.ToCString());
}
@@ -2028,9 +2023,9 @@ bool Logger::SetUp(Isolate* isolate) {
FLAG_log_snapshot_positions = true;
}
- SmartArrayPointer<const char> log_file_name =
- PrepareLogFileName(isolate, FLAG_logfile);
- log_->Initialize(log_file_name.get());
+ OStringStream log_file_name;
+ PrepareLogFileName(log_file_name, isolate, FLAG_logfile);
+ log_->Initialize(log_file_name.c_str());
if (FLAG_perf_basic_prof) {
@@ -2044,7 +2039,7 @@ bool Logger::SetUp(Isolate* isolate) {
}
if (FLAG_ll_prof) {
- ll_logger_ = new LowLevelLogger(log_file_name.get());
+ ll_logger_ = new LowLevelLogger(log_file_name.c_str());
addCodeEventListener(ll_logger_);
}
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698