+2
-3
Cargo.toml
+2
-3
Cargo.toml
···
4
4
edition = "2021"
5
5
6
6
[dependencies]
7
-
smallvec = { version = "1.13.2", optional = true }
7
+
smallvec = { version = "1.13.2" }
8
8
9
9
[features]
10
-
default = ["reclaim-memory", "smallvec"]
10
+
default = ["reclaim-memory"]
11
11
reclaim-memory = []
12
-
smallvec = ["dep:smallvec"]
13
12
timing = []
-11
src/main.rs
-11
src/main.rs
···
1
-
#[cfg(feature = "smallvec")]
2
1
use smallvec::SmallVec;
3
2
use std::io::{Read, Write};
4
3
#[cfg(feature = "timing")]
5
4
use std::time::Instant;
6
5
use um::{Operation, Parameter, Platter};
7
6
8
-
#[cfg(feature = "smallvec")]
9
7
const SMALLVEC_SIZE: usize = 24;
10
8
11
9
fn main() {
···
51
49
pub struct Um<'a> {
52
50
program_counter: Platter,
53
51
registers: [Platter; 8],
54
-
#[cfg(feature = "smallvec")]
55
52
memory: Vec<SmallVec<[Platter; SMALLVEC_SIZE]>>,
56
-
#[cfg(not(feature = "smallvec"))]
57
-
memory: Vec<Vec<Platter>>,
58
53
#[cfg(feature = "reclaim-memory")]
59
54
free_blocks: Vec<Platter>,
60
55
ops: Vec<Operation>,
···
366
361
)
367
362
}
368
363
369
-
#[cfg(feature = "smallvec")]
370
364
fn new_block(len: usize) -> SmallVec<[Platter; SMALLVEC_SIZE]> {
371
365
smallvec::smallvec![0; len]
372
-
}
373
-
374
-
#[cfg(not(feature = "smallvec"))]
375
-
fn new_block(len: usize) -> Vec<Platter> {
376
-
vec![0; len]
377
366
}
378
367
}