Flatten array of structs into several arrays in C++ -


source code understand situation:

struct s {      int i;      float f  }; const int cnt = 10;  s *source = new s[cnt]; /*... fill source ...*/  int *dest_i = new int[cnt]; float *dest_f = new float[cnt];  (int x = 0; x < cnt; x++) {     dest_i[x] = source[x].i;     dest_f[x] = source[x].f; } 

so, here question: there faster method iterate through array loop?

you unroll loop. that's can think of off top of head.

it's pointless optimization write yourself, compiler can try if enable (in gcc, compile --funroll-loops)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -