Add an EntityMap::get_or_default() method.
This covers a common pattern for secondary entity maps: Get the value in the map or the default value for out-of-range keys.
This commit is contained in:
@@ -64,7 +64,7 @@ pub fn relax_branches(func: &mut Function, isa: &TargetIsa) {
|
||||
}
|
||||
|
||||
while let Some(inst) = pos.next_inst() {
|
||||
let enc = func.encodings.get(inst).cloned().unwrap_or_default();
|
||||
let enc = func.encodings.get_or_default(inst);
|
||||
let size = encinfo.bytes(enc);
|
||||
|
||||
// See if this might be a branch that is out of range.
|
||||
|
||||
Reference in New Issue
Block a user