# @inbounds code slower than one without

**URL:** <https://discourse.julialang.org/t/inbounds-code-slower-than-one-without/21550>\
**Category:** General Usage\
**Created:** [March 6, 2019, 9:11pm UTC](https://discourse.julialang.org/t/inbounds-code-slower-than-one-without/21550 "2019-03-06T21:11:44Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [March 8, 2019, 3:55am UTC](https://discourse.julialang.org/t/inbounds-code-slower-than-one-without/21550/15 "2019-03-08T03:55:47Z")

</div>

Alright, for posterity, and since the documentation for `valloc` seems quite sparse, here’s the version I ended up with. Changing to use a `pointer`, `@simd` no longer makes a difference for me. I also optimized the iterator according to [our recent discussion](https://discourse.julialang.org/t/making-iterators-as-fast-as-loops/21377/18). Finally, with `valloc`, there’s no need to take care of the remaining elements at the end, since there’s extra room at the end to write an additional vector element.

```julia
function test_nt!(a::SubArray, n)
    v = Vec{4,Float64}((0, 1, 2, 3))
    for i = 0:(n-1)>>2
        vstorent(4i + 1 + v, pointer(a, 4i + 1))
    end
end

a = valloc(Float64, 8, 199)
test_nt!(a, 199)

```

---

_[View the full topic](https://discourse.julialang.org/t/inbounds-code-slower-than-one-without/21550)._
