Skip to content

Commit 1d1b344

Browse files
committed
Use entry API instead of a match
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.
1 parent 0a975e9 commit 1d1b344

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/cargo/ops/cargo_compile.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,11 @@ pub fn create_bcx<'a, 'cfg>(
475475
extra_args = Some(args);
476476
}
477477

478-
if let Some(mut args) = extra_args {
479-
match extra_compiler_args.get_mut(&unit) {
480-
None => {
481-
extra_compiler_args.insert(unit.clone(), args);
482-
}
483-
Some(existing) => existing.append(&mut args),
484-
}
478+
if let Some(args) = extra_args {
479+
extra_compiler_args
480+
.entry(unit.clone())
481+
.or_default()
482+
.extend(args);
485483
}
486484
}
487485
}

0 commit comments

Comments
 (0)