Explain runtime invariants and avoid redundant unwraps
This commit is contained in:
1 parent
34f2f07301
commit
1b51ba83b4
116 files changed
+1643
-515
No files matched your search
@@ -184,7 +184,15 @@ impl OutputWorkspaceMap {
|
||||
let mut removed = self
|
||||
.connected_outputs()
|
||||
.filter(|id| !desired.contains_key(id))
|
||||
.map(|id| (id, outputs.outputs.remove(&id).unwrap()))
|
||||
.map(|id| {
|
||||
(
|
||||
id,
|
||||
outputs
|
||||
.outputs
|
||||
.remove(&id)
|
||||
.expect("workspace reconciliation only accesses connected outputs"),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// Preserve the original focused workspace when several outputs vanish.
|
||||
removed.sort_by_key(|(id, _)| (Some(*id) == self.focused, *id));
|
||||
@@ -196,7 +204,10 @@ impl OutputWorkspaceMap {
|
||||
// against the final inventory, where that donor no longer needs it.
|
||||
for (id, record) in returning {
|
||||
let reclaimed = outputs.reclaim(id, &record);
|
||||
let state = outputs.outputs.get_mut(&id).unwrap();
|
||||
let state = outputs
|
||||
.outputs
|
||||
.get_mut(&id)
|
||||
.expect("workspace reconciliation only accesses connected outputs");
|
||||
state.workspaces.extend(reclaimed.iter().copied());
|
||||
if reclaimed.contains(&record.active) {
|
||||
state.activate(record.active);
|
||||
@@ -635,7 +646,7 @@ impl OutputWorkspaceMap {
|
||||
self.homes.insert(workspace, output);
|
||||
self.outputs
|
||||
.get_mut(&output)
|
||||
.unwrap()
|
||||
.expect("workspace reconciliation only accesses connected outputs")
|
||||
.workspaces
|
||||
.insert(workspace);
|
||||
self.bump_revision(workspace);
|
||||
|
||||
@@ -544,7 +544,10 @@ impl WorkspaceSet {
|
||||
replacements.push((workspace.id, layout));
|
||||
}
|
||||
for (id, layout) in replacements {
|
||||
self.workspaces.get_mut(&id).unwrap().layout = layout;
|
||||
self.workspaces
|
||||
.get_mut(&id)
|
||||
.expect("replacement layouts were built from existing workspace IDs")
|
||||
.layout = layout;
|
||||
}
|
||||
self.default_layout_mode = mode;
|
||||
self.default_column_width = width;
|
||||
|
||||
@@ -41,7 +41,10 @@ impl OutputWorkspaceMap {
|
||||
id,
|
||||
output,
|
||||
index: index as u32 + 1,
|
||||
window_count: workspaces.workspace(id).unwrap().window_count(),
|
||||
window_count: workspaces
|
||||
.workspace(id)
|
||||
.expect("workspace views enumerate registered workspace IDs")
|
||||
.window_count(),
|
||||
visible,
|
||||
focused: visible && self.focused_output() == Some(output),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user