Box up the BitVec array

The `Search::best` field will take about 8000 bytes. In some of our usage
with rayon, this appeared to cause stack overflows. Boxing it up makes the
code slower by about 1-2%, but should hopefully avoid stack overflows.
This commit is contained in:
Dirkjan Ochtman 2021-04-01 10:03:48 +02:00
parent a4fe0e4039
commit 2d942bbfc9
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "instant-segment"
version = "0.7.2"
version = "0.8.0"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
edition = "2018"
license = "Apache-2.0"

View File

@ -177,7 +177,7 @@ impl<'a> SegmentState<'a> {
#[derive(Clone)]
pub struct Search {
memo: HashMap<(u8, u8, u8), (f64, BitVec)>,
best: [BitVec; SEGMENT_SIZE],
best: Box<[BitVec; SEGMENT_SIZE]>,
result: Vec<String>,
}
@ -200,7 +200,7 @@ impl Default for Search {
fn default() -> Self {
Self {
memo: HashMap::default(),
best: [BitVec::default(); SEGMENT_SIZE],
best: Box::new([BitVec::default(); SEGMENT_SIZE]),
result: Vec::new(),
}
}