Skip to content

Commit 6b5d827

Browse files
ManciukicShadowCurse
authored andcommitted
refactor(pcie): avoid string format on good path
If a function is called in the `.ok_or`, this gets executed independently on whether the function succeeds or not, although the result is only used on failure. Replace it with a .ok_or_else to avoid a useless string allocation and memcpy. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 1e675c2 commit 6b5d827

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vmm/src/vstate/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl InterruptSourceGroup for MsiVectorGroup {
170170

171171
fn trigger(&self, index: InterruptIndex) -> vm_device::interrupt::Result<()> {
172172
self.notifier(index)
173-
.ok_or(std::io::Error::other(format!(
173+
.ok_or_else(|| std::io::Error::other(format!(
174174
"trigger: invalid interrupt index {index}"
175175
)))?
176176
.write(1)

0 commit comments

Comments
 (0)