cache optimizations
This commit is contained in:
parent
253b070a29
commit
35e1d5c016
@ -178,20 +178,20 @@ impl Function {
|
|||||||
.map(|ele| ele.x)
|
.map(|ele| ele.x)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let back_data: Vec<Value> = (1..=self.pixel_width)
|
self.back_cache = Some(
|
||||||
.map(|x| (x as f64 / resolution as f64) + min_x)
|
(1..=self.pixel_width)
|
||||||
.map(|x| {
|
.map(|x| (x as f64 / resolution as f64) + min_x)
|
||||||
let i = x_data.iter().position(|&r| r == x);
|
.map(|x| {
|
||||||
|
let i = x_data.iter().position(|&r| r == x);
|
||||||
|
|
||||||
if i.is_some() {
|
if i.is_some() {
|
||||||
back_cache[i.expect("i is None")]
|
back_cache[i.unwrap()]
|
||||||
} else {
|
} else {
|
||||||
Value::new(x, self.run_func(x))
|
Value::new(x, self.run_func(x))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect(),
|
||||||
|
);
|
||||||
self.back_cache = Some(back_data);
|
|
||||||
} else {
|
} else {
|
||||||
self.back_cache = None;
|
self.back_cache = None;
|
||||||
self.min_x = min_x;
|
self.min_x = min_x;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user