Which of these functions is type-unstable? If unstable:
- What are the performance implications?
- What’s the output in
@code_warntypethat would indicate instability?
(For the record: I know how to parameterize them; I’m trying to determine when parameterization makes sense.)
function foo1(v::Vector) T = eltype(v) return one(T) end
function foo2(v::Vector, x::Integer) T = eltype(v) oneT = one(T) # explicit assignment here just to make sure we allocate mem. return (oneT < x) end