On Saturday, 25 February 2017 at 11:15:53 UTC, ketmar wrote:
data pulverizer wrote:
I have noticed that some numerical packages written in D use
pointer semantics heavily (not referring to packages that link
to C libraries). I am in the process of writing code for a
numerical computing library and would like to know whether
there times when addressing an array using pointers conveys
performance benefits over using D's array or functional
semantics?
using `arr.ptr[n]` instead of `arr[n]` bypasses bounds
checking. this may be diserable in tight loops (while disabling
bounds checking globally is not).
but note that `foreach (int n; arr)` doesn't do bounds checking
in loop too (afair), so you prolly better use `foreach` instead
of pointers. this way your code will be fast, but still safe.
Thanks ketmar and thanks in advance to anyone else that comments.