Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
  • Loading branch information
samestep and jonmeow authored Nov 12, 2024
1 parent 311d0d1 commit 2138719
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion toolchain/base/timings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Timings {
map.Add("filename", filename);
map.Add("nanoseconds",
Yaml::OutputMapping([&](Yaml::OutputMapping::Map label_map) {
auto total_nanoseconds = std::chrono::nanoseconds(0);
std::chrono::nanoseconds total_nanoseconds(0);
for (const auto& entry : timings_) {
total_nanoseconds += entry.nanoseconds;
label_map.Add(entry.label, entry.nanoseconds.count());
Expand Down
6 changes: 3 additions & 3 deletions toolchain/check/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,9 @@ static auto CheckParseTree(
auto start_time = std::chrono::steady_clock::now();
CheckParseTreeInner(node_converters, unit_info, total_ir_count, vlog_stream);
auto end_time = std::chrono::steady_clock::now();
auto timings = unit_info.unit->timings;
if (timings) {
(*timings)->Add("check", end_time - start_time);
if (auto& timings = *(unit_info.unit->timings)) {
auto end_time = std::chrono::steady_clock::now();
timings->Add("check", end_time - start_time);
}
}

Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Carbon::Check {
// Checking information that's tracked per file.
struct Unit {
SharedValueStores* value_stores;
std::optional<Timings*> timings;
std::optional<Timings>* timings;
const Lex::TokenizedBuffer* tokens;
const Parse::Tree* parse_tree;
DiagnosticConsumer* consumer;
Expand Down
4 changes: 2 additions & 2 deletions toolchain/driver/compile_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class CompilationUnit {
CARBON_CHECK(parse_tree_);
return {
.value_stores = &value_stores_,
.timings = &*timings_,
.timings = &timings_,
.tokens = &*tokens_,
.parse_tree = &*parse_tree_,
.consumer = consumer_,
Expand Down Expand Up @@ -513,8 +513,8 @@ class CompilationUnit {
CARBON_CHECK(module_);
auto start_time = std::chrono::steady_clock::now();
LogCall("CodeGen", [&] { success_ = RunCodeGenHelper(); });
auto end_time = std::chrono::steady_clock::now();
if (timings_) {
auto end_time = std::chrono::steady_clock::now();
timings_->Add("codegen", end_time - start_time);
}
}
Expand Down

0 comments on commit 2138719

Please sign in to comment.