Using native-arrays by pointer vs normal indexing in a burst-compiled job

Hey guys,
I’ve been really into using Unity Job System for multithreaded code and I had some doubts regarding array iteration.
Is it in any way preferable to use pointers than the NativeArray struct’s indexer?
Using pointers means sometimes caching them as a struct field and it makes the struct size bigger by 8 bytes (on a 64-bit system), and I wonder if it actually gives any particular advantage.

Or is it fine if one uses the foreach iterator?

Solved - pointers are faster because of NativeContainer safety system, and can’t use foreach in burst.

1 Like