File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
src/abstractblocksparsearray Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 9696 end
9797 subblock_dest = @view block_dest[BI_dest. indices... ]
9898 subblock_srcs = ntuple (i -> @view (block_srcs[i][BI_srcs[i]. indices... ]), length (a_srcs))
99- if f_preserves_zeros && any ( ! iszero, subblock_srcs )
100- # TODO : Use `map!!` to handle immutable blocks.
101- map! (f, subblock_dest, subblock_srcs ... )
102- # Replace the entire block, handles initializing new blocks
103- # or if blocks are immutable.
104- blocks (a_dest)[ Int .( Tuple ( _block (BI_dest))) ... ] = block_dest
99+ I_dest = CartesianIndex ( Int .( Tuple ( _block (BI_dest))) )
100+ # If the function preserves zero values and all of the source blocks are zero,
101+ # the output block will be zero. In that case, if the block isn't stored yet,
102+ # don't do anything.
103+ if f_preserves_zeros && all (iszero, subblock_srcs) && ! isstored ( blocks (a_dest), I_dest)
104+ continue
105105 end
106+ # TODO : Use `map!!` to handle immutable blocks.
107+ map! (f, subblock_dest, subblock_srcs... )
108+ # Replace the entire block, handles initializing new blocks
109+ # or if blocks are immutable.
110+ blocks (a_dest)[I_dest] = block_dest
106111 end
107112 return a_dest
108113end
You can’t perform that action at this time.
0 commit comments