JuliaLang/julia — pull request #9324 by rfourquet (2014-12-12 06:55:54+00:00)
Title: refactor rand on UnitRange / AbstractArray

This is another approach to the (non-merged) refactoring part of #8309 and #8649.
The goal is to reduce to the minimum the different code paths taken by `UnitRange` and `AbstractArray` (`UnitRange`s are handled differently so that those with overflowing `length` still work).
In particular two `rand!` method are merged into one.

Only `rand(::UnitRange{Bool})` becomes slower (by 10-15%), as it is no more in the group of specially supported ranges, because arithmetic on them doesn't produce `Bool`, so they would need individual support (which I can easily add if requested).

Note: This change suggests another one (https://github.com/JuliaLang/julia/commit/0c6b81a31db1a42f86dde9844d4c12ef1d97e246): merge all other array filling methods.