Best way to access nested data structures?
Posted
by Blackshark
on Stack Overflow
See other posts from Stack Overflow
or by Blackshark
Published on 2010-06-03T19:17:04Z
Indexed on
2010/06/08
14:32 UTC
Read the original article
Hit count: 152
I would like to know what the best way (performance wise) to access a large data structure is. There are about hundred ways to do it but what is the most accessible for the compiler to optimize?
One can access a value by
foo[someindex].bar[indexlist[i].subelement[j]].baz[0]
or create some pointer aliases like
sometype_t* tmpfoo = &foo[someindex];
tmpfoo->bar[indexlist[i].subelement[j]].baz[0]
or create reference aliases like
sometype_t &tmpfoo = foo[someindex];
tmpfoo.bar[indexlist[i].subelement[j]].baz[0]
and so forth...
© Stack Overflow or respective owner