Skip to content

Commit 09f77f4

Browse files
Specialize on operations
1 parent 0523c23 commit 09f77f4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NullBroadcasts"
22
uuid = "0d71be07-595a-4f89-9529-4065a4ab43a6"
33
authors = ["CliMA Contributors <[email protected]>"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[compat]
77
Aqua = "0.8"

src/NullBroadcasts.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ Base.broadcasted(op::typeof(+), arg, ::NullBroadcasted, args...) =
5959
Base.broadcasted(op::typeof(+), a::NullBroadcasted, ::NullBroadcasted, args...) =
6060
Base.broadcasted(op, a, args...)
6161

62+
# Specialize on identity cases:
63+
Base.broadcasted(::typeof(+), ::NullBroadcasted, x) = x
64+
Base.broadcasted(::typeof(+), x, ::NullBroadcasted) = x
65+
Base.broadcasted(::typeof(-), x, ::NullBroadcasted) = x
66+
6267
Base.broadcasted(op::typeof(*), ::NullBroadcasted, args...) = NullBroadcasted()
6368
Base.broadcasted(op::typeof(*), arg, ::NullBroadcasted) = NullBroadcasted()
6469
Base.broadcasted(op::typeof(*), ::NullBroadcasted, ::NullBroadcasted) = NullBroadcasted()

0 commit comments

Comments
 (0)