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

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -