C pointers vs direct member access for structs

前端 未结 9 2757
抹茶落季
抹茶落季 2020-12-16 17:59

Say I have a struct like the following ...

typedef struct {
  int WheelCount;
  double MaxSpeed;
} Vehicle;

... and I have a global variabl

9条回答
  •  醉酒成梦
    2020-12-16 18:06

    Direct member access is faster (for pointers you'd get one pointer dereference operation more, typically). Although I'm having a hard time imagining it in a situation where it'd be a problem, performance or otherwise.

提交回复
热议问题