Performance drawback with subtyping

Try writing paint2 like this:

function paint2(p::Picture)
  s = 0.
  for l in p.lines
    if l isa LineA
      s += paint(l::LineA)
    else
      s += paint(l::LineB)
    end
  end
  s
end

Does that improve performance?

1 Like