Riccardo Lucchese <riccardo.lucchese@xxxxxxxxx> writes: > I'm working on GTK code; let's say we have some code like: > > widget->privData->color = ...; > widget->privData->l = ...; > widget->privData->w = ...; > widget->privData->foo = ...; > > does gcc already optimise widget->privData saving its value one time and > than using it? or generated binary just does what is written(literally - > "reference per reference")? It depends on the data types. If it is possible that the assignment to, e.g., widget->privData->color could change widget->privData itself (perhaps because widget->privData == widget), then gcc can not optimize the following load of widget->privData. > Would it be better to do: > WidgetPrivData* priv = widget->privData; > priv->color = ...; > priv->l = ...; > priv->w = ...; > priv->foo = ...; In some cases, yes. Ian