Skip to content

Commit 4a2e175

Browse files
committed
fixup! Revert "Test and fix non-int-length bug in view(::Memory, ::Union{UnitRange, Base.OneTo}) (#53991)"
1 parent e31ce7e commit 4a2e175

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

base/array.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -3081,7 +3081,7 @@ function _wrap(ref::MemoryRef{T}, dims::NTuple{N, Int}) where {T, N}
30813081
@boundscheck mem_len >= len || invalid_wrap_err(mem_len, dims, len)
30823082
if N != 1 && !(ref === GenericMemoryRef(mem) && len === mem_len)
30833083
mem = ccall(:jl_genericmemory_slice, Memory{T}, (Any, Ptr{Cvoid}, Int), mem, ref.ptr_or_offset, len)
3084-
ref = MemoryRef(mem)
3084+
ref = memoryref(mem)
30853085
end
30863086
return ref
30873087
end
@@ -3097,7 +3097,7 @@ end
30973097

30983098
@eval @propagate_inbounds function wrap(::Type{Array}, m::Memory{T}, dims::NTuple{N, Integer}) where {T, N}
30993099
dims = convert(Dims, dims)
3100-
ref = _wrap(MemoryRef(m), dims)
3100+
ref = _wrap(memoryref(m), dims)
31013101
$(Expr(:new, :(Array{T, N}), :ref, :dims))
31023102
end
31033103
@eval @propagate_inbounds function wrap(::Type{Array}, m::MemoryRef{T}, l::Integer) where {T}
@@ -3107,11 +3107,11 @@ end
31073107
end
31083108
@eval @propagate_inbounds function wrap(::Type{Array}, m::Memory{T}, l::Integer) where {T}
31093109
dims = (Int(l),)
3110-
ref = _wrap(MemoryRef(m), (l,))
3110+
ref = _wrap(memoryref(m), (l,))
31113111
$(Expr(:new, :(Array{T, 1}), :ref, :dims))
31123112
end
31133113
@eval @propagate_inbounds function wrap(::Type{Array}, m::Memory{T}) where {T}
3114-
ref = MemoryRef(m)
3114+
ref = memoryref(m)
31153115
dims = (length(m),)
31163116
$(Expr(:new, :(Array{T, 1}), :ref, :dims))
31173117
end

base/iobuffer.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ function take!(io::IOBuffer)
466466
if nbytes == 0 || io.reinit
467467
data = StringVector(0)
468468
elseif io.writable
469-
data = wrap(Array, MemoryRef(io.data, io.offset + 1), nbytes)
469+
data = wrap(Array, memoryref(io.data, io.offset + 1), nbytes)
470470
else
471471
data = copyto!(StringVector(nbytes), 1, io.data, io.offset + 1, nbytes)
472472
end
@@ -475,7 +475,7 @@ function take!(io::IOBuffer)
475475
if nbytes == 0
476476
data = StringVector(0)
477477
elseif io.writable
478-
data = wrap(Array, MemoryRef(io.data, io.ptr), nbytes)
478+
data = wrap(Array, memoryref(io.data, io.ptr), nbytes)
479479
else
480480
data = read!(io, data)
481481
end
@@ -503,8 +503,8 @@ Array allocation), as well as omits some checks.
503503
"""
504504
_unsafe_take!(io::IOBuffer) =
505505
wrap(Array, io.size == io.offset ?
506-
MemoryRef(Memory{UInt8}()) :
507-
MemoryRef(io.data, io.offset + 1),
506+
memoryref(Memory{UInt8}()) :
507+
memoryref(io.data, io.offset + 1),
508508
io.size - io.offset)
509509

510510
function write(to::IO, from::GenericIOBuffer)

0 commit comments

Comments
 (0)