Skip to content

Commit

Permalink
Remove redundant code, we do not need arrayrefs anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev committed May 21, 2024
1 parent fe6c671 commit f746b0b
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions hist/hist/src/TFormula.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ prepareMethod(bool HasParameters, bool HasVariables, const char* FuncName,
// We need an extra Double_t* for the gradient return result.
if (AddCladArrayRef) {
prototypeArguments.Append(",");
prototypeArguments.Append("clad::array_ref<Double_t>");
prototypeArguments.Append("Double_t*");
}

// Initialize the method call using real function name (cling name) defined
Expand Down Expand Up @@ -3177,24 +3177,13 @@ static void CallCladFunction(TInterpreter::CallFuncIFacePtr_t::Generic_t FuncPtr
} else {
// __attribute__((used)) extern "C" void __cf_0(void* obj, int nargs, void** args, void* ret)
// {
// ((void (&)(double*, double*,
// clad::array_ref<double>))TFormula____id_grad_1)(*(double**)args[0],
// *(double**)args[1],
// *(clad::array_ref<double> *)args[2]);
// ((void (&)(double*, double*, double*))TFormula____id_grad_1)(*(double**)args[0],
// *(double**)args[1],
// *(double**)args[2]);
// return;
// }
args[1] = &pars;

// Using the interpreter to obtain the pointer to clad::array_ref is too
// slow and we do not want to expose clad::array_ref to the interpreter
// so this struct acts as a lightweight implementation of it
struct array_ref_interface {
Double_t *arr;
std::size_t size;
};

array_ref_interface ari{result, static_cast<size_t>(result_size)};
args[2] = &ari;
args[2] = &result;
(*FuncPtr)(nullptr, 3, args, /*ret*/nullptr); // We do not use ret in a return-void func.
}
}
Expand Down Expand Up @@ -3604,7 +3593,7 @@ TString TFormula::GetExpFormula(Option_t *option) const

TString TFormula::GetGradientFormula() const {
std::unique_ptr<TInterpreterValue> v = gInterpreter->MakeInterpreterValue();
std::string s("(void (&)(Double_t *, Double_t *, clad::array_ref<Double_t>)) ");
std::string s("(void (&)(Double_t *, Double_t *, Double_t *)) ");
s += GetGradientFuncName();
gInterpreter->Evaluate(s.c_str(), *v);
return v->ToString();
Expand Down

0 comments on commit f746b0b

Please sign in to comment.