Computating order matters. Here we want to make sure pix is a dense memory with valid pointer. But we can compute it in one line, e.g., map(x->colors[x], @view(img[:, :, i])'). -- Vector and Matrix should be the same when you get the pointer of it so vec is needless.
The quantizers could possibly be improved, but doesn't have the bandwidth to check it 😢
Use MappedArrays to avoid allocating buffers for
res
at each iteration. This could be GC-heavy if the image itself is large.https://github.com/JuliaIO/GIFImages.jl/blob/c3b84d0045bd3b142ae91ab35c6b8b57ef5facbe/src/decode.jl#L62-L65
[]
is equivalent toAny[]
and is slow. Use Concrete types, e.g.,UInt8[]
?https://github.com/JuliaIO/GIFImages.jl/blob/c3b84d0045bd3b142ae91ab35c6b8b57ef5facbe/src/encode.jl#L35
colors
should also be a concret typeDict{RGB{N0f8}, UInt8}()
https://github.com/JuliaIO/GIFImages.jl/blob/c3b84d0045bd3b142ae91ab35c6b8b57ef5facbe/src/encode.jl#L48-L51
Computating order matters. Here we want to make sure
pix
is a dense memory with valid pointer. But we can compute it in one line, e.g.,map(x->colors[x], @view(img[:, :, i])')
. --Vector
andMatrix
should be the same when you get the pointer of it sovec
is needless.https://github.com/JuliaIO/GIFImages.jl/blob/c3b84d0045bd3b142ae91ab35c6b8b57ef5facbe/src/encode.jl#L67-L68