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.
This commit is contained in:
Joshua Nelson 2020-07-04 15:47:26 -04:00
parent 0a975e96d8
commit 1d1b344781

View File

@ -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);
}
}
}