From 034e6475ea107756bbcaf16118c51382d4a80f24 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Fri, 28 Mar 2025 12:38:55 +0100 Subject: [PATCH 1/3] `Base`: shell escaping: inference improvement to prevent invalidation Should make the sysimage more resistant to invalidation. --- base/shell.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/shell.jl b/base/shell.jl index e07fff128acfe..b83cf9ad6412b 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -344,7 +344,7 @@ function shell_escape_csh(io::IO, args::AbstractString...) end shell_escape_csh(args::AbstractString...) = sprint(shell_escape_csh, args...; - sizehint = sum(sizeof.(args)) + length(args) * 3) + sizehint = mapreduce(sizeof, +, args; init = 0) + length(args) * 3) """ shell_escape_wincmd(s::AbstractString) @@ -494,4 +494,4 @@ function escape_microsoft_c_args(io::IO, args::AbstractString...) end escape_microsoft_c_args(args::AbstractString...) = sprint(escape_microsoft_c_args, args...; - sizehint = (sum(sizeof.(args)) + 3*length(args))) + sizehint = (mapreduce(sizeof, +, args; init = 0) + 3*length(args))) From 92e5d9dae097ad6579b57b8902ca318c734cb1ee Mon Sep 17 00:00:00 2001 From: Neven Sajko <4944410+nsajko@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:46:55 +0100 Subject: [PATCH 2/3] 2-arg `sum` instead of `mapreduce` Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com> --- base/shell.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/shell.jl b/base/shell.jl index b83cf9ad6412b..27297b4b606b1 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -344,7 +344,7 @@ function shell_escape_csh(io::IO, args::AbstractString...) end shell_escape_csh(args::AbstractString...) = sprint(shell_escape_csh, args...; - sizehint = mapreduce(sizeof, +, args; init = 0) + length(args) * 3) + sizehint = sum(sizeof, args) + length(args) * 3) """ shell_escape_wincmd(s::AbstractString) From 2873cdde7c644f13aea6168da5a01e6b3d77c3fd Mon Sep 17 00:00:00 2001 From: Neven Sajko <4944410+nsajko@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:47:38 +0100 Subject: [PATCH 3/3] more of the same --- base/shell.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/shell.jl b/base/shell.jl index 27297b4b606b1..68925cbd5d5af 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -494,4 +494,4 @@ function escape_microsoft_c_args(io::IO, args::AbstractString...) end escape_microsoft_c_args(args::AbstractString...) = sprint(escape_microsoft_c_args, args...; - sizehint = (mapreduce(sizeof, +, args; init = 0) + 3*length(args))) + sizehint = (sum(sizeof, args) + 3*length(args)))