Skip to content

Commit

Permalink
Reduce allocations and branching in transform_code_lengths_to_code
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored and GunnarFarneback committed Sep 24, 2024
1 parent b04ce13 commit a143c73
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/Inflate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,10 @@ function getdist(data::AbstractInflateData)
end

function transform_code_lengths_to_code(code_lengths::Vector{Int})
code = Vector{Int}[]
code = [Int[] for _ in 1:maximum(code_lengths)]
for i = 1:length(code_lengths)
n = code_lengths[i]
if n > 0
while n > length(code)
push!(code, Int[])
end
push!(code[n], i - 1)
end
end
Expand Down

0 comments on commit a143c73

Please sign in to comment.