Sun 26 Aug 2012 10:22:08 PM UTC, comment #3:
Hello Pawel.
I see three reasons for use of inline function.
The first one is when you have a function called many times in cycle and you want for performance reason to strip out the opening and closing sequence for function calling.
The second reason is a small function when the opening and closing sequence for function calling is bigger then a body of the function. GCC can do it automagicaly with -finline-small-functions (included in -O2 switch).
The third reason for inline is when you split a bigger function to small functions and these small functions are called only on one place in program. GCC can do it automagicaly with -finline-functions-called-once.
I looked to smsd and there are only 4 inline functions.
InsertEvent(), FreeElement() and FreeArray () are reasonable small functions on the first look and in case of FreeElement() there is also a performance reason.
RemoveEvent() looks to be bigger but when you look at the code and forgot the long variables and functions names, it is very simple few lines function. And it is called only on one place in a cycle.
I didn't looked to xgnokii source for many years.
I was little bit surprised when I saw result of grep. But most of them are 1 to 3 lines functions. The bigger function are:
xgnokii.c:DrawNetwork()
xgnokii.c:DrawBattery()
xgnokii_sms.c:RefreshFolder()
xgnokii_lowlevel.c:RemoveEvent()
Above functions are called only on one place in code and are called frequently.
xgnokii_contacts.c:OkDialVoiceDialog()
Above function is called only on one place in code
And following functions need not be inline:
xgnokii_contacts.c:RefreshUserStatusCallBack()
xgnokii_contacts.c:GUI_GetEntry()
xgnokii.c:GUI_ShowContacts()
xgnokii.c:GUI_ShowSMS()
xgnokii_netmon.c:RefreshDisplay()
xgnokii_sms.c:RefreshSMSStatus()
|