Skip to content

Commit

Permalink
1.11: improve type stability of _unsafe_take!(::IOBuffer) (#54942)
Browse files Browse the repository at this point in the history
fixes #54900
  • Loading branch information
aviatesk committed Jun 27, 2024
1 parent 6cf82f9 commit b7af64f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3082,8 +3082,10 @@ function _wrap(ref::MemoryRef{T}, dims::NTuple{N, Int}) where {T, N}
return ref
end

@noinline invalid_wrap_err(len, dims, proddims) = throw(DimensionMismatch(
"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."))
@noinline invalid_wrap_err(len, dims, proddims) = throw(DimensionMismatch(LazyString(
"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.")))

@eval @propagate_inbounds function wrap(::Type{Array}, m::MemoryRef{T}, dims::NTuple{N, Integer}) where {T, N}
dims = convert(Dims, dims)
Expand Down
2 changes: 1 addition & 1 deletion base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function sprint(f::Function, args...; context=nothing, sizehint::Integer=0)
String(_unsafe_take!(s))
end

function _str_sizehint(x)
function _str_sizehint(@nospecialize x)
if x isa Float64
return 20
elseif x isa Float32
Expand Down

0 comments on commit b7af64f

Please sign in to comment.