aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2025-02-03 06:46:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2025-02-03 06:48:19 +0200
commit43eb1e43b6b22a0343104387431db7f32a88b16c (patch)
tree15b90b59ac4748bfa923190eb91952b5a613992b /libbuild2/cc
parent4ed0fe15d139748784adb40841028b36704b2f4f (diff)
Optimize maybe-used diag_record
It turns out the std::ostringstream member of butl::diag_record is quite expensive to construct but to never use.
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/compile-rule.cxx28
-rw-r--r--libbuild2/cc/msvc.cxx4
2 files changed, 15 insertions, 17 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index c8955bc..53d38ac 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -2350,9 +2350,9 @@ namespace build2
if (verb > 2)
{
- diag_record dr;
- dr << error << "header " << f << " not found and no "
- << "rule to generate it";
+ diag_record dr (error);
+ dr << "header " << f << " not found and no rule to "
+ << "generate it";
if (verb < 4)
dr << info << "re-run with --verbose=4 for more information";
@@ -2925,8 +2925,8 @@ namespace build2
if (verb > 2)
{
- diag_record dr;
- dr << error << "header '" << f << "' not found";
+ diag_record dr (error);
+ dr << "header '" << f << "' not found";
if (verb < 4)
dr << info << "re-run with --verbose=4 for more information";
@@ -4060,9 +4060,8 @@ namespace build2
//
bool df (!ctx.match_only && !ctx.dry_run_option);
- diag_record dr;
- dr << error << "header " << h << " not found and no rule to "
- << "generate it";
+ diag_record dr (error);
+ dr << "header " << h << " not found and no rule to generate it";
if (df)
dr << info << "failure deferred to compiler diagnostics";
@@ -4134,9 +4133,8 @@ namespace build2
//
bool df (!ctx.match_only && !ctx.dry_run_option);
- diag_record dr;
- dr << error << "header " << hp << " not found and no rule to "
- << "generate it";
+ diag_record dr (error);
+ dr << "header " << hp << " not found and no rule to generate it";
if (df)
dr << info << "failure deferred to compiler diagnostics";
@@ -4985,7 +4983,7 @@ namespace build2
if (pr.wait ())
{
{
- diag_record dr;
+ maybe_diag_record dr;
if (bad_error)
dr << fail << "expected error exit status from "
@@ -5093,7 +5091,7 @@ namespace build2
// preprocessed source files).
//
{
- diag_record dr;
+ maybe_diag_record dr;
if (force_gen_skip && *force_gen_skip == skip_count)
{
dr <<
@@ -5101,11 +5099,11 @@ namespace build2
info << "run the following two commands to investigate";
dr << info;
- print_process (dr, args.data ()); // No pipes.
+ print_process (*dr, args.data ()); // No pipes.
init_args ((gen = true));
dr << info << "";
- print_process (dr, args.data ()); // No pipes.
+ print_process (*dr, args.data ()); // No pipes.
}
if (dbuf.is_open ())
diff --git a/libbuild2/cc/msvc.cxx b/libbuild2/cc/msvc.cxx
index 416df36..66223b5 100644
--- a/libbuild2/cc/msvc.cxx
+++ b/libbuild2/cc/msvc.cxx
@@ -511,8 +511,8 @@ namespace build2
if (!run_finish_code (args, pr, s, 2 /* verbosity */) || io)
{
- diag_record dr;
- dr << warn << "unable to detect " << l << " library type, ignoring" <<
+ diag_record dr (warn);
+ dr << "unable to detect " << l << " library type, ignoring" <<
info << "run the following command to investigate" <<
info; print_process (dr, args);
return otype::e;