J
junky_fellow
Guys,
typedef struct {
unsigned int count;
unsigned short id;
unsigned char cell[3];
} XYZInfo;
#define INFO_ITEM \
{ 0x7080A000, 0xB990, { 0x20, 0x30, 0x40 }}
func (void)
{
static XYZInfo s_itemInfo = INFO_ITEM; /* case 1 */
XYZInfo itemInfo = INFO_ITEM; /* case 2 */
..
..
}
My question is which one is better in terms of cpu time. I believe,
for case 1, the structure is initialized at compile time and should be
more efficient than case 2, where the structure will be initialized at
run time.
Is that right ?
typedef struct {
unsigned int count;
unsigned short id;
unsigned char cell[3];
} XYZInfo;
#define INFO_ITEM \
{ 0x7080A000, 0xB990, { 0x20, 0x30, 0x40 }}
func (void)
{
static XYZInfo s_itemInfo = INFO_ITEM; /* case 1 */
XYZInfo itemInfo = INFO_ITEM; /* case 2 */
..
..
}
My question is which one is better in terms of cpu time. I believe,
for case 1, the structure is initialized at compile time and should be
more efficient than case 2, where the structure will be initialized at
run time.
Is that right ?