Lift return out of if-statements

This commit is contained in:
tygyh 2022-07-15 16:36:11 +02:00
parent 25e20b5fa0
commit abdd5e3906
2 changed files with 27 additions and 22 deletions

View File

@ -333,11 +333,11 @@ impl KeyMouse {
return format!("Mouse {}", button + 3); return format!("Mouse {}", button + 3);
}, },
ScanKey(scancode) => { ScanKey(scancode) => {
if let Some(layout) = key_layout { return if let Some(layout) = key_layout {
return layout.get_key_as_string(*scancode); layout.get_key_as_string(*scancode)
} else { } else {
return format!("Unknown (0x{:X})", scancode); format!("Unknown (0x{:X})", scancode)
} };
}, },
}; };

View File

@ -349,14 +349,14 @@ impl Archetype for House {
// Chimney // Chimney
if center_offset.map(|e| e.abs()).reduce_max() <= 1 && profile.y < chimney_top { if center_offset.map(|e| e.abs()).reduce_max() <= 1 && profile.y < chimney_top {
// Fireplace // Fireplace
if center_offset.product() == 0 return if center_offset.product() == 0
&& profile.y > foundation_height + 1 && profile.y > foundation_height + 1
&& profile.y <= foundation_height + 3 && profile.y <= foundation_height + 3
{ {
return internal; internal
} else { } else {
return foundation; foundation
} };
} }
} }
@ -372,12 +372,15 @@ impl Archetype for House {
} }
} }
if dist < width && profile.y < foundation_height && profile.y >= foundation_height - 3 { return if dist < width
&& profile.y < foundation_height
&& profile.y >= foundation_height - 3
{
// Basement // Basement
return internal; internal
} else { } else {
return foundation.with_priority(1); foundation.with_priority(1)
} };
} }
// Roofs and walls // Roofs and walls
@ -406,13 +409,15 @@ impl Archetype for House {
if profile.y == roof_level && roof_dist <= width + 2 { if profile.y == roof_level && roof_dist <= width + 2 {
let is_ribbing = ((profile.y - ceil_height) % 3 == 0 && self.roof_ribbing) let is_ribbing = ((profile.y - ceil_height) % 3 == 0 && self.roof_ribbing)
|| (bound_offset.x == bound_offset.y && self.roof_ribbing_diagonal); || (bound_offset.x == bound_offset.y && self.roof_ribbing_diagonal);
if (roof_profile.x == 0 && mansard == 0) || roof_dist == width + 2 || is_ribbing return if (roof_profile.x == 0 && mansard == 0)
|| roof_dist == width + 2
|| is_ribbing
{ {
// Eaves // Eaves
return log; log
} else { } else {
return roof; roof
} };
} }
// Wall // Wall
@ -456,13 +461,13 @@ impl Archetype for House {
}; };
} }
if bound_offset.x == bound_offset.y || profile.y == ceil_height { return if bound_offset.x == bound_offset.y || profile.y == ceil_height {
// Support beams // Support beams
return log; log
} else if !attr.storey_fill.has_lower() && profile.y < ceil_height } else if !attr.storey_fill.has_lower() && profile.y < ceil_height
|| !attr.storey_fill.has_upper() || !attr.storey_fill.has_upper()
{ {
return EMPTY; EMPTY
} else { } else {
let (frame_bounds, frame_borders) = if profile.y >= ceil_height { let (frame_bounds, frame_borders) = if profile.y >= ceil_height {
( (
@ -500,13 +505,13 @@ impl Archetype for House {
} }
// Wall // Wall
return if attr.central_supports && profile.x == 0 { if attr.central_supports && profile.x == 0 {
// Support beams // Support beams
log.with_priority(structural_layer) log.with_priority(structural_layer)
} else { } else {
wall wall
}; }
} };
} }
if dist < width { if dist < width {