Skip to content

Commit

Permalink
refactor: use Cow on artifact notification
Browse files Browse the repository at this point in the history
`artifact` field is an (absolute) path to emitted artifact like
/home/projects/foo/target/debug/deps/libbar-73d672db2af2c9a8.rmeta

It is worth not copying them.
  • Loading branch information
weihanglo committed Sep 27, 2024
1 parent cdba1c7 commit d6b740f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1852,11 +1852,12 @@ fn on_stderr_line_inner(
// Look for a matching directive and inform Cargo internally that a
// metadata file has been produced.
#[derive(serde::Deserialize)]
struct ArtifactNotification {
artifact: String,
struct ArtifactNotification<'a> {
#[serde(borrow)]
artifact: Cow<'a, str>,
}

if let Ok(artifact) = serde_json::from_str::<ArtifactNotification>(compiler_message.get()) {
if let Ok(artifact) = serde_json::from_str::<ArtifactNotification<'_>>(compiler_message.get()) {
trace!("found directive from rustc: `{}`", artifact.artifact);
if artifact.artifact.ends_with(".rmeta") {
debug!("looks like metadata finished early!");
Expand Down

0 comments on commit d6b740f

Please sign in to comment.