From dd728df53b3e8e5eba6c58ed7638bfc03d5fcff9 Mon Sep 17 00:00:00 2001 From: Axel Naumann <Axel.Naumann@cern.ch> Date: Mon, 3 Dec 2018 17:53:57 +0100 Subject: [PATCH] Merge pull request #3061 from Axel-Naumann/TFormulaTriggerAutoParse [TFormula] Allow autoparsing to hit before Declare() (ROOT-9840) --- hist/hist/src/TFormula.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hist/hist/src/TFormula.cxx b/hist/hist/src/TFormula.cxx index 7dcb9f4be96..d89e20eb9f6 100644 --- a/hist/hist/src/TFormula.cxx +++ b/hist/hist/src/TFormula.cxx @@ -823,8 +823,16 @@ void TFormula::InputFormulaIntoCling() // make sure the interpreter is initialized ROOT::GetROOT(); R__ASSERT(gCling); + + // Trigger autoloading / autoparsing (ROOT-9840): + TString triggerAutoparsing = "namespace ROOT_TFormula_triggerAutoParse {\n"; triggerAutoparsing += fClingInput + "\n}"; + gCling->ProcessLine(triggerAutoparsing); + // add pragma for optimization of the formula fClingInput = TString("#pragma cling optimize(2)\n") + fClingInput; + + // Now that all libraries and headers are loaded, Declare() a performant version + // of the same code: gCling->Declare(fClingInput); fClingInitialized = PrepareEvalMethod(); if (!fClingInitialized) Error("InputFormulaIntoCling","Error compiling formula expression in Cling"); -- GitLab