Function and gradient evaluation in same function Ipopt

I am using Ipopt.jl as my optimizer and would like to compute the function value and its gradient in the same Julia function (for performance reasons).

See this example:
Here the function value and gradient and hessian are all specified with a different Julia function. I however need the function value to compute my gradient, so I end up calculating it anyway in my gradient evaluation function (thereby computing it twice).

Is there a workaround such that one can combine the function and gradient evaluation in the same Julia call? In the same way as NLopt.jl does that?

Ok, I tried that already, and that didn’t seem to be any faster. But must have done something wrong there then. Thanks.