Skip to content

Commit 479436a

Browse files
authored
Avoid extra allocations when reading (#66)
* avoid extra allocations when reading * Bump version to 2.1.6
1 parent 019b2c1 commit 479436a

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ZipArchives"
22
uuid = "49080126-0e18-4c2a-b176-c102e4b3760c"
33
authors = ["nhz2 <[email protected]>"]
4-
version = "2.1.5"
4+
version = "2.1.6"
55

66
[deps]
77
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"

src/reader.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ function zip_crc32(data::AbstractVector{UInt8}, crc::UInt32=UInt32(0))::UInt32
3535
zip_crc32(collect(data), crc)
3636
end
3737

38-
# Copied from ZipFile.jl
39-
readle(io::IO, ::Type{UInt64}) = htol(read(io, UInt64))
40-
readle(io::IO, ::Type{UInt32}) = htol(read(io, UInt32))
41-
readle(io::IO, ::Type{UInt16}) = htol(read(io, UInt16))
42-
readle(io::IO, ::Type{UInt8}) = read(io, UInt8)
43-
38+
@inline readle(io::IO, ::Type{UInt64}) = UInt64(readle(io, UInt32)) | UInt64(readle(io, UInt32))<<32
39+
@inline readle(io::IO, ::Type{UInt32}) = UInt32(readle(io, UInt16)) | UInt32(readle(io, UInt16))<<16
40+
@inline readle(io::IO, ::Type{UInt16}) = UInt16(read(io, UInt8)) | UInt16(read(io, UInt8))<<8
41+
@inline readle(io::IO, ::Type{UInt8}) = read(io, UInt8)
4442

4543
#=
4644
Return the minimum size of a local header for an entry.

0 commit comments

Comments
 (0)