Skip to content

Commit b7af64f

Browse files
authored
1.11: improve type stability of _unsafe_take!(::IOBuffer) (#54942)
fixes #54900
1 parent 6cf82f9 commit b7af64f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

base/array.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,10 @@ function _wrap(ref::MemoryRef{T}, dims::NTuple{N, Int}) where {T, N}
30823082
return ref
30833083
end
30843084

3085-
@noinline invalid_wrap_err(len, dims, proddims) = throw(DimensionMismatch(
3086-
"Attempted to wrap a MemoryRef of length $len with an Array of size dims=$dims, which is invalid because prod(dims) = $proddims > $len, so that the array would have more elements than the underlying memory can store."))
3085+
@noinline invalid_wrap_err(len, dims, proddims) = throw(DimensionMismatch(LazyString(
3086+
"Attempted to wrap a MemoryRef of length ", len, " with an Array of size dims=", dims,
3087+
" which is invalid because prod(dims) = ", proddims, " > ", len,
3088+
" so that the array would have more elements than the underlying memory can store.")))
30873089

30883090
@eval @propagate_inbounds function wrap(::Type{Array}, m::MemoryRef{T}, dims::NTuple{N, Integer}) where {T, N}
30893091
dims = convert(Dims, dims)

base/strings/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function sprint(f::Function, args...; context=nothing, sizehint::Integer=0)
116116
String(_unsafe_take!(s))
117117
end
118118

119-
function _str_sizehint(x)
119+
function _str_sizehint(@nospecialize x)
120120
if x isa Float64
121121
return 20
122122
elseif x isa Float32

0 commit comments

Comments
 (0)