JuliaLang/julia — pull request #9140 by nolta (2014-11-24 22:28:37+00:00)
Title: _methods(): merge identical methods

This is my (probably wrong) attempt to address the comments on 847a6facf3268aa386959d96f712dc612a3fe2ce.

When passing Union types to `_methods()`, a separate method was returned for each member of the Union. This defeated inlining when all the methods were identical.

Before:

julia> Base._methods(next, (Union(Int,Float64),Int), -1)
2-element Array{Any,1}:
((Float64,Int64),(),next(x::Number,state) at number.jl:37)
((Int64,Int64),(),next(x::Number,state) at number.jl:37)

After:

julia> Base._methods(next, (Union(Int,Float64),Int), -1)
1-element Array{Any,1}:
((Union(Float64,Int64),Int64),(),next(x::Number,state) at number.jl:37)

With this patch, the `vocab.jl` test in #8826 is 1.6x faster, because `next` and `done` are inlined.

cc @JeffBezanson @vtjnash