It’s totally necessary, because:
z[56:end] .-= 1
is equivalent to
z[56:end] .= z[56:end] .- 1
and the slice z[56:end]
on the right-hand side allocates a copy.
I also find it a lot clearer in most cases to just put @views
on the whole function rather than on individual lines.
@views function test4(z)
z[56:end] .-= 1
end
giving
julia> @btime test4($z);
1.681 μs (0 allocations: 0 bytes)