Skip to content

Avoid type pirating Base.skip #150

@KristofferC

Description

@KristofferC

This function seems a bit odd to define here:

Tar.jl/src/Tar.jl

Lines 12 to 21 in 6bfc114

function Base.skip(io::Union{Base.Process, Base.ProcessChain}, n::Integer)
n < 0 && throw(ArgumentError("cannot skip backwards when reading from a process"))
isempty(skip_buffer) && resize!(skip_buffer, DEFAULT_BUFFER_SIZE)
while n > 0
n -= readbytes!(io, skip_buffer, min(n, length(skip_buffer)))
end
# TODO: our skip data should throw if there's not enough data
return io
end
const skip_buffer = UInt8[]

It also has some issues, like referencing a global skip_buffer (so the function is not thread-safe).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions