Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.11: improve type stability of _unsafe_take!(::IOBuffer) #54942

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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