@@ -285,88 +285,40 @@ impl FunctionEntry {
285
285
self . clear_integral ( ) ;
286
286
}
287
287
288
- let mut partial_regen = false ;
289
-
290
- if width_changed {
291
- self . clear_back ( ) ;
292
- self . clear_derivative ( ) ;
293
- } else if min_max_changed && !self . back_data . is_empty ( ) && !did_zoom && {
294
- let prev_min = unsafe { self . back_data . first ( ) . unwrap_unchecked ( ) } . x ;
295
- let min_i = ( ( settings. min_x - prev_min) as f64 / resolution) as usize ;
296
- ( prev_min < settings. min_x ) && ( ( self . back_data . len ( ) - 1 ) > min_i)
297
- } {
298
- partial_regen = true ;
299
- let prev_min = unsafe { self . back_data . first ( ) . unwrap_unchecked ( ) } . x ;
300
-
301
- let min_i = ( ( settings. min_x - prev_min) as f64 / resolution) as usize ;
302
-
303
- {
304
- let _ = self . back_data . drain ( min_i..=settings. plot_width ) ;
305
-
306
- let mut new_data: Vec < Value > = ( min_i..=settings. plot_width )
307
- . map ( move |x : usize | ( x as f64 * resolution) + settings. min_x )
308
- . map ( |x : f64 | Value :: new ( x, self . function . get ( x) ) )
309
- . collect ( ) ;
310
- self . back_data . append ( & mut new_data) ;
311
- debug_assert_eq ! ( self . back_data. len( ) , settings. plot_width + 1 ) ;
312
- }
313
-
314
- {
315
- let _ = self . derivative_data . drain ( min_i..=settings. plot_width ) ;
316
-
317
- let mut new_data: Vec < Value > = ( min_i..=settings. plot_width )
318
- . map ( move |x : usize | ( x as f64 * resolution) + settings. min_x )
319
- . map ( |x : f64 | Value :: new ( x, self . function . get_derivative_1 ( x) ) )
320
- . collect ( ) ;
321
- self . derivative_data . append ( & mut new_data) ;
322
- debug_assert_eq ! ( self . derivative_data. len( ) , settings. plot_width + 1 ) ;
323
- }
324
-
325
- if self . nth_derviative && let Some ( data) = self . nth_derivative_data . as_mut ( ) {
326
- let _ = data. drain ( min_i..=settings. plot_width ) ;
327
-
328
- let mut new_data: Vec < Value > = ( min_i..=settings. plot_width )
329
- . map ( move |x : usize | ( x as f64 * resolution) + settings. min_x )
330
- . map ( |x : f64 | Value :: new ( x, self . function . get_nth_derivative ( self . curr_nth , x) ) )
331
- . collect ( ) ;
332
- data. append ( & mut new_data) ;
333
- debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
334
- }
335
- } else {
288
+ if width_changed | min_max_changed | did_zoom {
336
289
self . clear_back ( ) ;
337
290
self . clear_derivative ( ) ;
291
+ self . clear_nth ( ) ;
338
292
}
339
293
340
- if !partial_regen {
341
- if self . back_data . is_empty ( ) {
342
- let data: Vec < Value > = resolution_iter
343
- . clone ( )
344
- . into_iter ( )
345
- . map ( |x| Value :: new ( x, self . function . get ( x) ) )
346
- . collect ( ) ;
347
- debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
294
+ if self . back_data . is_empty ( ) {
295
+ let data: Vec < Value > = resolution_iter
296
+ . clone ( )
297
+ . into_iter ( )
298
+ . map ( |x| Value :: new ( x, self . function . get ( x) ) )
299
+ . collect ( ) ;
300
+ debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
348
301
349
- self . back_data = data;
350
- }
302
+ self . back_data = data;
303
+ }
351
304
352
- if self . derivative_data . is_empty ( ) {
353
- let data: Vec < Value > = resolution_iter
354
- . clone ( )
355
- . into_iter ( )
356
- . map ( |x| Value :: new ( x, self . function . get_derivative_1 ( x) ) )
357
- . collect ( ) ;
358
- debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
359
- self . derivative_data = data;
360
- }
305
+ if self . derivative_data . is_empty ( ) {
306
+ let data: Vec < Value > = resolution_iter
307
+ . clone ( )
308
+ . into_iter ( )
309
+ . map ( |x| Value :: new ( x, self . function . get_derivative_1 ( x) ) )
310
+ . collect ( ) ;
311
+ debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
312
+ self . derivative_data = data;
313
+ }
361
314
362
- if self . nth_derviative && self . nth_derivative_data . is_none ( ) {
363
- let data: Vec < Value > = resolution_iter
364
- . into_iter ( )
365
- . map ( |x| Value :: new ( x, self . function . get_nth_derivative ( self . curr_nth , x) ) )
366
- . collect ( ) ;
367
- debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
368
- self . nth_derivative_data = Some ( data) ;
369
- }
315
+ if self . nth_derviative && self . nth_derivative_data . is_none ( ) {
316
+ let data: Vec < Value > = resolution_iter
317
+ . into_iter ( )
318
+ . map ( |x| Value :: new ( x, self . function . get_nth_derivative ( self . curr_nth , x) ) )
319
+ . collect ( ) ;
320
+ debug_assert_eq ! ( data. len( ) , settings. plot_width + 1 ) ;
321
+ self . nth_derivative_data = Some ( data) ;
370
322
}
371
323
372
324
if self . integral {
0 commit comments