Skip to content

Commit 3628ead

Browse files
committed
Make LogicVMBuilder::build_with_globals take ref instead of cow
1 parent 4d583f6 commit 3628ead

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/bin/mlogv32.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(dead_code)]
22

33
use std::{
4-
borrow::Cow,
54
collections::VecDeque,
65
error::Error,
76
fmt::Display,
@@ -520,7 +519,7 @@ fn main() -> Result<(), Box<dyn Error>> {
520519
println!("Finalizing VM...");
521520

522521
let globals = LVar::create_global_constants();
523-
let vm = builder.build_with_globals(Cow::Borrowed(&globals))?;
522+
let vm = builder.build_with_globals(&globals)?;
524523

525524
let uart_fifo_modulo = meta.uart_fifo_capacity + 1;
526525

src/vm/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloc::{borrow::Cow, rc::Rc, string::String, vec::Vec};
1+
use alloc::{rc::Rc, string::String, vec::Vec};
22
use core::{cell::Cell, time::Duration};
33
#[cfg(feature = "std")]
44
use std::time::Instant;
@@ -188,10 +188,10 @@ impl LogicVMBuilder {
188188
}
189189

190190
pub fn build(self) -> VMLoadResult<LogicVM> {
191-
self.build_with_globals(Cow::Owned(LVar::create_global_constants()))
191+
self.build_with_globals(&LVar::create_global_constants())
192192
}
193193

194-
pub fn build_with_globals(mut self, globals: Cow<'_, Constants>) -> VMLoadResult<LogicVM> {
194+
pub fn build_with_globals(mut self, globals: &Constants) -> VMLoadResult<LogicVM> {
195195
// sort processors in update order
196196
// 7 8 9
197197
// 4 5 6
@@ -227,7 +227,7 @@ impl LogicVMBuilder {
227227
.data
228228
.borrow_mut()
229229
.unwrap_processor_mut()
230-
.late_init(&vm, processor, &globals)?;
230+
.late_init(&vm, processor, globals)?;
231231
}
232232

233233
Ok(vm)
@@ -272,7 +272,7 @@ pub enum VMLoadError {
272272

273273
#[cfg(all(test, not(feature = "std"), feature = "no_std"))]
274274
mod tests {
275-
use alloc::{borrow::Cow, boxed::Box, rc::Rc, vec};
275+
use alloc::{boxed::Box, rc::Rc, vec};
276276
use core::{cell::RefCell, time::Duration};
277277

278278
use pretty_assertions::assert_eq;
@@ -336,7 +336,7 @@ mod tests {
336336
},
337337
&builder,
338338
)]);
339-
let vm = builder.build_with_globals(Cow::Owned(globals)).unwrap();
339+
let vm = builder.build_with_globals(&globals).unwrap();
340340

341341
vm.do_tick(Duration::ZERO);
342342

@@ -419,7 +419,7 @@ mod tests {
419419
)
420420
.unwrap(),
421421
);
422-
builder.build_with_globals(Cow::Borrowed(globals)).unwrap()
422+
builder.build_with_globals(globals).unwrap()
423423
}
424424

425425
fn run(vm: &mut LogicVM, max_ticks: usize, want: bool) {

0 commit comments

Comments
 (0)