Skip to content

Commit

Permalink
avoid unnecessary clones
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui authored and barthalion committed Jan 10, 2022
1 parent 4e6ac18 commit 7bfca06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ pub fn start_job_executor(
start_executor(&None, &config, &delta_generator, &pool),
);

for repo in config.repos.keys().cloned() {
for repo in config.repos.keys() {
executors.insert(
Some(repo.clone()),
start_executor(&Some(repo.clone()), &config, &delta_generator, &pool),
Expand Down
20 changes: 10 additions & 10 deletions src/ostree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ fn get_object_path(repo_path: &path::Path, object: &str, object_type: &str) -> p
let mut path = std::env::current_dir().unwrap_or_default();
path.push(repo_path);
path.push("objects");
path.push(object[0..2].to_string());
path.push(&object[0..2]);
path.push(format!("{}.{}", &object[2..], object_type));
path
}
Expand Down Expand Up @@ -722,9 +722,9 @@ pub fn get_delta_superblock(
delta: &str,
) -> OstreeResult<OstreeDeltaSuperblock> {
let mut path = get_deltas_path(repo_path);
path.push(delta[0..2].to_string());
path.push(delta[2..].to_string());
path.push("superblock".to_string());
path.push(&delta[0..2]);
path.push(&delta[2..]);
path.push("superblock");

load_delta_superblock_file(&path)
}
Expand Down Expand Up @@ -765,7 +765,7 @@ pub struct Delta {
}

fn delta_part_to_hex(part: &str) -> OstreeResult<String> {
let bytes = base64::decode(&part.replace("_", "/")).map_err(|err| {
let bytes = base64::decode(&part.replace('_', "/")).map_err(|err| {
OstreeError::InternalError(format!("Invalid delta part name '{}': {}", part, err))
})?;
Ok(bytes_to_object(&bytes))
Expand All @@ -774,7 +774,7 @@ fn delta_part_to_hex(part: &str) -> OstreeResult<String> {
fn hex_to_delta_part(hex: &str) -> OstreeResult<String> {
let bytes = object_to_bytes(hex)?;
let part = base64::encode_config(&bytes, base64::STANDARD_NO_PAD);
Ok(part.replace("/", "_"))
Ok(part.replace('/', "_"))
}

impl Delta {
Expand Down Expand Up @@ -813,16 +813,16 @@ impl Delta {
pub fn delta_path(&self, repo_path: &path::Path) -> OstreeResult<path::PathBuf> {
let mut path = get_deltas_path(repo_path);
let name = self.to_name()?;
path.push(name[0..2].to_string());
path.push(name[2..].to_string());
path.push(&name[0..2]);
path.push(&name[2..]);
Ok(path)
}

pub fn tmp_delta_path(&self, repo_path: &path::Path) -> OstreeResult<path::PathBuf> {
let mut path = get_tmp_deltas_path(repo_path);
let name = self.to_name()?;
path.push(name[0..2].to_string());
path.push(name[2..].to_string());
path.push(&name[0..2]);
path.push(&name[2..]);
Ok(path)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ClaimsValidator for HttpRequest {

fn has_token_repo(&self, repo: &str) -> Result<(), ApiError> {
self.validate_claims(|claims| {
if !repo_matches_one_claimed(&repo.to_string(), &claims.repos) {
if !repo_matches_one_claimed(repo, &claims.repos) {
return Err(ApiError::NotEnoughPermissions(
"Not matching repo in token".to_string(),
));
Expand Down

0 comments on commit 7bfca06

Please sign in to comment.