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

support for IOBuffer containing Memory #1125

Merged
merged 4 commits into from
Feb 28, 2024
Merged
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
9 changes: 9 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@
# one-liner suggested from ScottPJones
consumeBOM(buf, pos) = (length(buf) >= 3 && buf[pos] == 0xef && buf[pos + 1] == 0xbb && buf[pos + 2] == 0xbf) ? pos + 3 : pos

if isdefined(Base,:wrap)
__wrap(x,pos) = Base.wrap(Array,x,pos)
else
__wrap(x,pos) = x

Check warning on line 251 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L251

Added line #L251 was not covered by tests
end

# whatever input is given, turn it into an AbstractVector{UInt8} we can parse with
@inline function getbytebuffer(x, buffer_in_memory)
tfile = nothing
Expand All @@ -260,6 +266,9 @@
elseif x.data isa SubArray{UInt8}
x = x.data
return parent(x), first(x.indices), last(x.indices), tfile
else #support from IOBuffer containing Memory
y = __wrap(x.data,length(x.data)) #generates a Vector{UInt8} from Memory{UInt8}
return y, x.ptr, x.size, tfile
end
elseif x isa Cmd || x isa IO
if buffer_in_memory
Expand Down
Loading