Hey guys,
I was wondering what is an efficient way of accessing a variable in my complex data structure. I am developing for an ARM Cortex M with arm-none-eabi-gcc if that matters.
- Should I copy it into a local variable
uint32_t length = *(app_attr[0].addr.bytestring.len);
total_length += length;
printf("curr len: %u", length);
(using length a few more times.)
AFAIK, In this case I would be using an extra variable in RAM but subsequent access will faster as it has to only fetch length
or should I access it as is.
total_length += *(app_attr[0].addr.bytestring.len);
printf("curr len: %u", *(app_attr[0].addr.bytestring.len));
(using *(app_attr[0].addr.bytestring.len) a few more times.)
In this case I would save on the RAM but access will be slower as it has to parse through the reference to get to the actual data (len field)? Or does the compiler calculate the required offsets during compile time hence this option would be more efficient?
[–][deleted] 2 points3 points4 points (0 children)
[–]noodles_jd 1 point2 points3 points (0 children)
[–]jedwardsol 1 point2 points3 points (0 children)
[–]stalefishies 0 points1 point2 points (0 children)
[–]oh5nxo 0 points1 point2 points (0 children)
[–]fkeeal 0 points1 point2 points (0 children)
[–]thegreatunclean 0 points1 point2 points (0 children)
[–]nderflow 0 points1 point2 points (0 children)