Skip to content

Commit 139dcd9

Browse files
authored
revert some performance-losing changes to max_args (#59673)
This heuristic normally helps ensure good code performance. Overriding it (as was done in 97ecdb8) is observed to cause allocation regressions. Fix #58632
1 parent c4683c4 commit 139dcd9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

base/strings/io.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ function print(io::IO, xs...)
5151
return nothing
5252
end
5353

54-
setfield!(typeof(print).name, :max_args, Int32(10), :monotonic)
55-
5654
"""
5755
println([io::IO], xs...)
5856
@@ -75,8 +73,6 @@ julia> takestring!(io)
7573
```
7674
"""
7775
println(io::IO, xs...) = print(io, xs..., "\n")
78-
79-
setfield!(typeof(println).name, :max_args, Int32(10), :monotonic)
8076
## conversion of general objects to strings ##
8177

8278
"""
@@ -148,7 +144,6 @@ function print_to_string(xs...)
148144
end
149145
takestring!(s)
150146
end
151-
setfield!(typeof(print_to_string).name, :max_args, Int32(10), :monotonic)
152147

153148
function string_with_env(env, xs...)
154149
if isempty(xs)

contrib/juliac/juliac-trim-base.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ end
7777
print(io, T.var.name)
7878
end
7979
end
80-
# this function is not `--trim`-compatible if it resolves to a Varargs{...} specialization
80+
# these functions are not `--trim`-compatible if it resolves to a Varargs{...} specialization
8181
# and since it only has 1-argument methods this happens too often by default (just 2-3 args)
8282
setfield!(typeof(throw_eachindex_mismatch_indices).name, :max_args, Int32(5), :monotonic)
83+
setfield!(typeof(print).name, :max_args, Int32(10), :monotonic)
84+
setfield!(typeof(println).name, :max_args, Int32(10), :monotonic)
85+
setfield!(typeof(print_to_string).name, :max_args, Int32(10), :monotonic)
8386
end
8487
@eval Base.Sys begin
8588
__init_build() = nothing # VersionNumber parsing is not supported yet

0 commit comments

Comments
 (0)