Skip to content

Commit 028c977

Browse files
JeffBezansonKristofferC
authored andcommitted
specialize show of : to make reshape trimmable (#59598)
I also noticed that the standard Base.show_type_name appears to be trimmable so we don't need the override. We might still want it for code size, but probably not a big deal. (cherry picked from commit 12f7bb5)
1 parent ba3b093 commit 028c977

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

base/essentials.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,10 @@ struct Colon <: Function
10091009
end
10101010
const (:) = Colon()
10111011

1012+
function show(io::IO, ::Colon)
1013+
show_type_name(io, Colon.name)
1014+
print(io, "()")
1015+
end
10121016

10131017
"""
10141018
Val(c)

contrib/juliac/juliac-trim-base.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ end
7777
print(io, T.var.name)
7878
end
7979
end
80-
show_type_name(io::IO, tn::Core.TypeName) = print(io, tn.name)
8180

8281
mapreduce(f::F, op::F2, A::AbstractArrayOrBroadcasted; dims=:, init=_InitialValue()) where {F, F2} =
8382
_mapreduce_dim(f, op, init, A, dims)

test/trimming/trimmability.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ function @main(args::Vector{String})::Cint
5050
catch
5151
end
5252

53+
Base.donotdelete(reshape([1,2,3],:,1,1))
54+
5355
return 0
5456
end

0 commit comments

Comments
 (0)