On Wed, Nov 16, 2016 at 10:06 AM, FANG Colin <colinf...@gmail.com> wrote:
> In performance tips, it says
>
> Essentially, Val{T}works only when T is either hard-coded (Val{3}) or
> already specified in the type-domain.
>
> Suppose I have
>
> ff(::Type{Val{1}}) = 1
>
> I guess the following is on a slower route.
>
> x = 1
> a = ff(::Type{Val{x}})
>
> And maybe this one can be determined in compile time
>
> const y = 1
> a = ff(::Type{Val{y}})
>
> How can I tell if it is fast or slow? @code_warntype doesn't tell the
> difference here?

Both of these are slow since it's in the global scope. (although I'm
not sure exactly what you are checking since none of these are valid
syntax.) If you are doing it in a local scope then code_warntype
should be enough.

Reply via email to