Skip to content

Commit

Permalink
Fewer temporary needless strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Aug 30, 2023
1 parent 743d4ab commit c47a858
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions credential/cargo-credential/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub enum Error {
}

impl From<String> for Error {
fn from(err: String) -> Self {
fn from(message: String) -> Self {
Box::new(StringTypedError {
message: err.to_string(),
message,
source: None,
})
.into()
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
.env("NUM_JOBS", &bcx.jobs().to_string())
.env("TARGET", bcx.target_data.short_name(&unit.kind))
.env("DEBUG", debug.to_string())
.env("OPT_LEVEL", &unit.profile.opt_level.to_string())
.env("OPT_LEVEL", &unit.profile.opt_level)
.env(
"PROFILE",
match unit.profile.root {
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
let mut rustc = prepare_rustc(cx, unit)?;
let build_plan = cx.bcx.build_config.build_plan;

let name = unit.pkg.name().to_string();
let name = unit.pkg.name();
let buildkey = unit.buildkey();

let outputs = cx.outputs(unit)?;
Expand Down Expand Up @@ -785,7 +785,7 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> {
paths::create_dir_all(&doc_dir)?;

let target_desc = unit.target.description_named();
let name = unit.pkg.name().to_string();
let name = unit.pkg.name();
let build_script_outputs = Arc::clone(&cx.build_script_outputs);
let package_id = unit.pkg.package_id();
let manifest_path = PathBuf::from(unit.pkg.manifest_path());
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ pub struct Downloads<'a, 'cfg> {
/// Total bytes for all successfully downloaded packages.
downloaded_bytes: u64,
/// Size (in bytes) and package name of the largest downloaded package.
largest: (u64, String),
largest: (u64, InternedString),
/// Time when downloading started.
start: Instant,
/// Indicates *all* downloads were successful.
Expand Down Expand Up @@ -459,7 +459,7 @@ impl<'cfg> PackageSet<'cfg> {
))),
downloads_finished: 0,
downloaded_bytes: 0,
largest: (0, String::new()),
largest: (0, InternedString::new("")),
success: false,
updated_at: Cell::new(Instant::now()),
timeout,
Expand Down Expand Up @@ -891,7 +891,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
self.downloads_finished += 1;
self.downloaded_bytes += dl.total.get();
if dl.total.get() > self.largest.0 {
self.largest = (dl.total.get(), dl.id.name().to_string());
self.largest = (dl.total.get(), dl.id.name());
}

// We're about to synchronously extract the crate below. While we're
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/resolver/dep_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl RequirementError {
)),
Some(p) => ActivateError::Conflict(
p,
ConflictReason::MissingFeatures(feat.to_string()),
ConflictReason::MissingFeatures(feat),
),
};
}
Expand Down Expand Up @@ -577,7 +577,7 @@ impl RequirementError {
// and `dep:` syntax is not allowed in a dependency.
Some(p) => ActivateError::Conflict(
p,
ConflictReason::MissingFeatures(dep_name.to_string()),
ConflictReason::MissingFeatures(dep_name),
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub enum ConflictReason {
/// A dependency listed features that weren't actually available on the
/// candidate. For example we tried to activate feature `foo` but the
/// candidate we're activating didn't actually have the feature `foo`.
MissingFeatures(String),
MissingFeatures(InternedString),

/// A dependency listed a feature that ended up being a required dependency.
/// For example we tried to activate feature `foo` but the
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ impl TomlManifest {
let mut names_sources = BTreeMap::new();
for dep in &deps {
let name = dep.name_in_toml();
let prev = names_sources.insert(name.to_string(), dep.source_id());
let prev = names_sources.insert(name, dep.source_id());
if prev.is_some() && prev != Some(dep.source_id()) {
bail!(
"Dependency '{}' has different source paths depending on the build \
Expand Down

0 comments on commit c47a858

Please sign in to comment.