# Can I make my code faster with parallelism, or just plain better coding?

**URL:** <https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613>\
**Category:** Performance\
**Created:** [February 9, 2019, 7:57pm UTC](https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613 "2019-02-09T19:57:40Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [February 15, 2019, 8:35am UTC](https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613/19 "2019-02-15T08:35:27Z")

</div>

> [@MrRobot](#):
>
> But, if I try to update a SVector in my `SingleLJ2!` function, it fails, I get `ERROR: LoadError: setindex! ::SArray{Tuple{3},Float64,1,3}, value, ::Int) is not defined.`

I think you misread @aaowens’s code, this `A[i] += abc` means “copy `abc` to location `i` of vector `A`”. This works because `A` is mutable (even though its elements are not). Thus `A[i][1] += B[i][1]` would not work because `A[i][1]` is a field of a SVector and thus cannot be updated.

To fill an SVector, see [Constructing SVector with a loop - #7 by tkf](https://discourse.julialang.org/t/constructing-svector-with-a-loop/15372/7). But for your example just do `SVector(-fdx, -fdy, f*dz)`.

---

_[View the full topic](https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613)._
