From 304836f41a92cdb873635825cbf78e5d7939d10c Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Sun, 3 Apr 2022 18:03:03 +0200 Subject: [PATCH] Nasal: optimises properties in lp filter Use geNode instead of getprop --- Nasal/aircraft.nas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Nasal/aircraft.nas b/Nasal/aircraft.nas index 2831da3f4..abe6f92bd 100644 --- a/Nasal/aircraft.nas +++ b/Nasal/aircraft.nas @@ -254,6 +254,7 @@ var lowpass = { var m = { parents: [lowpass] }; m.coeff = coeff >= 0 ? coeff : die("aircraft.lowpass(): coefficient must be >= 0"); m.value = nil; + m.delta_sec_node = props.globals.getNode("/sim/time/delta-sec",1); return m; }, # filter(raw_value) -> push new value, returns filtered value @@ -270,9 +271,9 @@ var lowpass = { me.value = v; }, _filter_: func(v) { - var dt = getprop("/sim/time/delta-sec"); - var c = dt / (me.coeff + dt); - me.value = v * c + me.value * (1 - c); + me.dt = me.delta_sec_node.getValue(); + me.c = me.dt / (me.coeff + me.dt); + me.value = v * me.c + me.value * (1 - me.c); }, };