nak: use filter() instead of open-coding it

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38807>
This commit is contained in:
Eric Engestrom 2025-10-06 16:09:36 +02:00
parent 314144ba51
commit 28ff39fbb4

View file

@ -8918,15 +8918,7 @@ impl BasicBlock {
}
pub fn branch(&self) -> Option<&Instr> {
if let Some(i) = self.instrs.last() {
if i.is_branch() {
Some(i)
} else {
None
}
} else {
None
}
self.instrs.last().filter(|&i| i.is_branch())
}
pub fn branch_ip(&self) -> Option<usize> {
@ -8943,15 +8935,7 @@ impl BasicBlock {
#[allow(dead_code)]
pub fn branch_mut(&mut self) -> Option<&mut Instr> {
if let Some(i) = self.instrs.last_mut() {
if i.is_branch() {
Some(i)
} else {
None
}
} else {
None
}
self.instrs.last_mut().filter(|i| i.is_branch())
}
pub fn falls_through(&self) -> bool {