diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2023-01-12 20:14:31 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2023-01-12 20:14:31 +0100 |
| commit | cd8ec6c787e147667e3bf43145873dd8e27755d0 (patch) | |
| tree | 02edfd9765a6e36fb3aab70265de29e69b9228b3 | |
| parent | 8a23ad17f8fa4f11335eb51215234af95cb9821d (diff) | |
| download | rust-cd8ec6c787e147667e3bf43145873dd8e27755d0.tar.gz rust-cd8ec6c787e147667e3bf43145873dd8e27755d0.zip | |
Add note on optimization in format args ast lowering.
| -rw-r--r-- | compiler/rustc_ast_lowering/src/format.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index d5da1a666f9..8985f8ad85d 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -223,6 +223,9 @@ fn expand_format_args<'hir>( // in order, we can use a simple array instead of a `match` construction. // However, if there's a yield point in any argument except the first one, // we don't do this, because an ArgumentV1 cannot be kept across yield points. + // + // This is an optimization, speeding up compilation about 1-2% in some cases. + // See https://perf.rust-lang.org/compare.html?start=5dbee4d3a6728eb4530fb66c9775834438ecec74&end=e36affffe97378a0027b4bcfbb18d27356164ed0&stat=instructions:u let use_simple_array = argmap.len() == arguments.len() && argmap.iter().enumerate().all(|(i, &(j, _))| i == j) && arguments.iter().skip(1).all(|arg| !may_contain_yield_point(&arg.expr)); |
