Skip to content

Commit

Permalink
Merge pull request tlnagy#33 from IanButterworth/ib/permuteddimsarray
Browse files Browse the repository at this point in the history
Write optimization via caching. Add SnoopCompile precompile directives
  • Loading branch information
tlnagy authored Feb 24, 2021
2 parents 737d133 + 3175019 commit 5f7e640
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/types/dense.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Base: @propagate_inbounds

struct DenseTaggedImage{T, N, O <: Unsigned,AA <: AbstractArray} <: AbstractDenseTIFF{T, N}
struct DenseTaggedImage{T, N, O <: Unsigned, AA <: AbstractArray} <: AbstractDenseTIFF{T, N}
data::AA
ifds::Vector{IFD{O}}

Expand Down Expand Up @@ -88,10 +88,12 @@ function Base.write(io::Stream, img::DenseTaggedImage)

prev_ifd_record = write(tf) # record that will have be updated

pagecache = Matrix{UInt8}(undef, size(img.data, 2) * sizeof(eltype(img.data)), size(img.data, 1))

for (idx, ifd) in enumerate(img.ifds)
data_pos = position(tf.io) # start of data

write(tf, reinterpret(UInt8, permutedims(view(img.data, :, :, idx), [2, 1]))) # write data
pagecache .= reinterpret(UInt8, PermutedDimsArray(view(img.data, :, :, idx), (2, 1)))
write(tf, pagecache) # write data
ifd_pos = position(tf.io)

# update record of previous IFD to point to this new IFD
Expand Down

0 comments on commit 5f7e640

Please sign in to comment.