only test function if it changed

This commit is contained in:
Simon Gardling 2022-02-28 10:17:39 -05:00
parent 0520904e7e
commit 4f5a541604

View File

@ -163,6 +163,7 @@ impl epi::App for MathApp {
ui.add(egui::Slider::new(&mut self.integral_num, INTEGRAL_NUM_RANGE).text("Interval")); ui.add(egui::Slider::new(&mut self.integral_num, INTEGRAL_NUM_RANGE).text("Interval"));
for (i, function) in self.functions.iter_mut().enumerate() { for (i, function) in self.functions.iter_mut().enumerate() {
let old_func_str = self.func_strs[i].clone();
let mut integral_toggle: bool = false; let mut integral_toggle: bool = false;
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Function: "); ui.label("Function: ");
@ -178,15 +179,18 @@ impl epi::App for MathApp {
function.is_integral() function.is_integral()
}; };
if !self.func_strs[i].is_empty() {
let proc_func_str = add_asterisks(self.func_strs[i].clone()); let proc_func_str = add_asterisks(self.func_strs[i].clone());
let mut do_update: bool = true;
if !self.func_strs[i].is_empty() && (proc_func_str != old_func_str) {
let func_test_output = test_func(proc_func_str.clone()); let func_test_output = test_func(proc_func_str.clone());
if !func_test_output.is_empty() { if !func_test_output.is_empty() {
parse_error += &func_test_output; parse_error += &func_test_output;
} else { do_update = false;
function.update(proc_func_str, integral, Some(self.integral_min_x), Some(self.integral_max_x), Some(self.integral_num));
} }
} }
if do_update {
function.update(proc_func_str, integral, Some(self.integral_min_x), Some(self.integral_max_x), Some(self.integral_num));
}
} }
// Opensource and Licensing information // Opensource and Licensing information