Skip to content

Commit

Permalink
Use entry API instead of a match
Browse files Browse the repository at this point in the history
This makes the code easier to read and also avoids looking up the
position in the map twice. The clone of `unit` is very cheap since it is
an Rc.
  • Loading branch information
jyn514 committed Jul 4, 2020
1 parent 0a975e9 commit 1d1b344
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,11 @@ pub fn create_bcx<'a, 'cfg>(
extra_args = Some(args);
}

if let Some(mut args) = extra_args {
match extra_compiler_args.get_mut(&unit) {
None => {
extra_compiler_args.insert(unit.clone(), args);
}
Some(existing) => existing.append(&mut args),
}
if let Some(args) = extra_args {
extra_compiler_args
.entry(unit.clone())
.or_default()
.extend(args);
}
}
}
Expand Down

0 comments on commit 1d1b344

Please sign in to comment.