Skip to content

Commit 16ee6bc

Browse files
committed
Use promotion rather than typejoin to infer map/broadcast output eltype
This allows `Union`s as the output type for mixtures of `Null` and numeric types, which can be more efficient than the `Any` you'd get from typejoin, at least in 0.7.
1 parent 0d292c9 commit 16ee6bc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ end
105105
return quote
106106
@_inline_meta
107107
elements = tuple($(exprs...))
108-
@inbounds return similar_type($first_staticarray, eltype(elements), Size($newsize))(elements)
108+
@inbounds return similar_type($first_staticarray, promote_tuple_eltype(elements), Size($newsize))(elements)
109109
end
110110
end
111111

src/mapreduce.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525
return quote
2626
@_inline_meta
2727
elements = tuple($(exprs...))
28-
@inbounds return similar_type(typeof(_first(a...)), eltype(elements), Size(S))(elements)
28+
@inbounds return similar_type(typeof(_first(a...)), promote_tuple_eltype(elements), Size(S))(elements)
2929
end
3030
end
3131

@@ -126,7 +126,7 @@ end
126126
return quote
127127
@_inline_meta
128128
elements = tuple($(exprs...))
129-
@inbounds return similar_type(a, eltype(elements), Size($Snew))(elements)
129+
@inbounds return similar_type(a, promote_tuple_eltype(elements), Size($Snew))(elements)
130130
end
131131
end
132132

0 commit comments

Comments
 (0)