I have two very similar functions that differ in only which function they
call
function search_suspects_forward(...)
...
searchsortedfirst(...)
end
function search_suspects_backward(...)
...
searchsortedlast(...)
end
function foo()
search_suspects_forward(...)
end
Naturally, I'd like to refactor the common code
function search_suspects(..., search_fun::Function)
...
search_fun(...)
end
search_suspects_foward(...) = search_suspects(..., searchsortedfirst)
...
But Julia doesn't specialize search_suspects based on search_fun (at least
on 0.4), which is a missed optimization opportunity. Is there any way to do
that? I could turn `search_fun` into a functor, but that kinda sucks (is
there a way to do that automatically?) If I understand inlining heuristics
correctly, I would expect that `search_suspects_forward`, being a short
function, will be inlined into `foo`, but what I want is for
`search_suspects` to be inlined into `search_suspects_forward`. Are there
ways of communicating that to the compiler? Is there a @notinline?