Figure 4a. Splitting functions to facilitate inlining.
5.1274 10000 Widget *WidgetHome::GetWidgetPointer()
{
1.0333 10000 if(widgetPtr == NULL)
{
0.0012 10 widgetPtr = new Widget;
0.0013 10 if(widgetPtr == NULL ||
widgetPtr->isError())
0.0000 0 return NULL;
}
1.0237 10000 return widgetPtr;
3.5429 10000 }
Figure 4b. Inlining only the part called most often.
// the inline doesn't show up on the profile count:
inline Widget *WidgetHome::GetWidgetPointer()
{
return widgetPtr ?
widgetPtr:
PrivateGetWidgetPointer();
}
0.0020 10 Widget *WidgetHome::PrivateGetWidgetPointer();
{
0.0059 10 widgetPtr = new Widget;
0.0035 10 if(widgetPtr == NULL ||
widgetPtr->isError())
0.0000 0 return NULL;
0.0008 10 return widgetPtr;
0.0001 10 }
// End of File