[問題] 請教關於執行效率
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
N/A
問題(Question):
typedef struct _AAA{
int a;
int b;
int c;
}AAA_T;
AAA_T aaa_db[10];
想請教板上各位先進
在function裡面
對於global structure以下兩種access aaa_db的方式
在執行效率是否有什麼不同?
如果考慮執行過程中有可能會被更高priority的ISR插斷
是否有哪一種做法較好呢?
Method 1 :
void test1(uint8 idx)
{
AAA_T *aaa_db_p = &aaa_db[idx];
aaa_db_p->a++;
aaa_db_p->b++;
aaa_db_p->c++;
}
Method 2 :
void test2(uint8 idx)
{
aaa_db[idx].a++;
aaa_db[idx].b++;
aaa_db[idx].c++;
}
感謝感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.143.71.224
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1428041102.A.E53.html
推
04/03 14:48, , 1F
04/03 14:48, 1F
→
04/03 14:49, , 2F
04/03 14:49, 2F
→
04/03 14:51, , 3F
04/03 14:51, 3F
→
04/03 14:54, , 4F
04/03 14:54, 4F
→
04/04 00:24, , 5F
04/04 00:24, 5F
→
04/04 09:15, , 6F
04/04 09:15, 6F
→
04/04 09:16, , 7F
04/04 09:16, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章