From 95ad4feeaf72ae9e9128b84160b5c0532f194c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Tue, 24 Dec 2024 17:12:33 +0100 Subject: [PATCH] Fix performance regression on models with many nested model-local variables without leads/lags The regression was introduced in commit 84d792bced340c52d90cd962e51e22eec605cea0, when leads/lags were allowed on model-local variables. The treatment of model-local variables without leads/lags was negatively impacted. This commit fixes the regression by restoring the former behaviour for model-local variables without leads/lags. Reported on https://forum.dynare.org/t/pre-processing-takes-very-long/26865 Ref. dynare#1929 --- src/DataTree.hh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DataTree.hh b/src/DataTree.hh index a0fe9185..38ff89ac 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -367,7 +367,13 @@ public: if (it == local_variables_table.end()) throw UnknownLocalVariableException {symb_id}; - return it->second->decreaseLeadsLags(-lead_lag); + /* In the following, the case without lead/lag is optimized. It makes a difference on models + with many nested model-local variables, see e.g. + https://forum.dynare.org/t/pre-processing-takes-very-long/26865 */ + if (lead_lag == 0) + return it->second; + else + return it->second->decreaseLeadsLags(-lead_lag); } static void -- GitLab