Click here to Skip to main content
15,902,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Error when call function lstrlenA in kernel32.dll(VC++6.0) Pin
KarstenK14-Aug-08 21:44
mveKarstenK14-Aug-08 21:44 
GeneralRe: Error when call function lstrlenA in kernel32.dll(VC++6.0) Pin
enhzflep15-Aug-08 3:21
enhzflep15-Aug-08 3:21 
GeneralRe: Error when call function lstrlenA in kernel32.dll(VC++6.0) Pin
David Crow15-Aug-08 4:05
David Crow15-Aug-08 4:05 
AnswerRe: Error when call function lstrlenA in kernel32.dll(VC++6.0) Pin
Mark Salsbery15-Aug-08 8:51
Mark Salsbery15-Aug-08 8:51 
Questiondelete efficiency question Pin
followait14-Aug-08 16:23
followait14-Aug-08 16:23 
AnswerRe: delete efficiency question Pin
Mark Salsbery14-Aug-08 16:27
Mark Salsbery14-Aug-08 16:27 
AnswerRe: delete efficiency question Pin
Jijo.Raj14-Aug-08 19:23
Jijo.Raj14-Aug-08 19:23 
GeneralRe: delete efficiency question Pin
Stephen Hewitt14-Aug-08 21:16
Stephen Hewitt14-Aug-08 21:16 
Jijo raj wrote:
and obviously its a few clock cycles less efficient than "delete p;".


At first I thought that but upon further thought I've become more cautious about jumping to that conclusion. The if case will generate code something like this:
004010FA 85 C0                test        eax,eax
004010FC 74 07                je          main+15h (00401105)
004010FE 50                   push        eax
004010FF E8 A4 20 00 00       call        operator delete (004031a8)
00401104 59                   pop         ecx


In the case where the pointer is NULL the branch at 0x004010FC jumps over the function call and thus avoids its overhead, which could well include growing the stack, cache misses, function prolog and epilogs, etc.

In the case where no explicit if is used the function call is always taken and the if is inside there somewhere.

Depending on how likely it is that the pointer is NULL the version with the if might well be faster; if the pointer is never NULL, or at least unlikely to be NULL, then the version without the if will be faster. Like many things it's not as simple as it first appears.

Steve

GeneralRe: delete efficiency question Pin
Roger Stoltz14-Aug-08 21:38
Roger Stoltz14-Aug-08 21:38 
GeneralRe: delete efficiency question Pin
Stephen Hewitt14-Aug-08 21:40
Stephen Hewitt14-Aug-08 21:40 
GeneralRe: delete efficiency question Pin
Jijo.Raj15-Aug-08 1:15
Jijo.Raj15-Aug-08 1:15 
GeneralRe: delete efficiency question Pin
Mark Salsbery15-Aug-08 5:07
Mark Salsbery15-Aug-08 5:07 
AnswerRe: delete efficiency question Pin
Roger Stoltz15-Aug-08 5:19
Roger Stoltz15-Aug-08 5:19 
GeneralRe: delete efficiency question Pin
Mark Salsbery15-Aug-08 6:01
Mark Salsbery15-Aug-08 6:01 
GeneralRe: delete efficiency question Pin
Stephen Hewitt17-Aug-08 15:46
Stephen Hewitt17-Aug-08 15:46 
Questionapahce sever - writestring - assertion failed Pin
simon alec smith14-Aug-08 14:45
simon alec smith14-Aug-08 14:45 
QuestionAccess Violation error in MFC Pin
Larry Mills Sr14-Aug-08 7:03
Larry Mills Sr14-Aug-08 7:03 
AnswerRe: Access Violation error in MFC Pin
Reagan Conservative14-Aug-08 8:29
Reagan Conservative14-Aug-08 8:29 
GeneralRe: Access Violation error in MFC Pin
Larry Mills Sr14-Aug-08 10:05
Larry Mills Sr14-Aug-08 10:05 
QuestionHow to get SysMonthCal32 to display in the dialog font when a theme is active? Pin
Keith Worden14-Aug-08 6:52
Keith Worden14-Aug-08 6:52 
QuestionASp.NEt how to delete a row from a grid Pin
reogeo200814-Aug-08 6:28
reogeo200814-Aug-08 6:28 
AnswerRe: ASp.NEt how to delete a row from a grid Pin
Mark Salsbery14-Aug-08 6:44
Mark Salsbery14-Aug-08 6:44 
GeneralRe: ASp.NEt how to delete a row from a grid Pin
Jijo.Raj14-Aug-08 20:28
Jijo.Raj14-Aug-08 20:28 
QuestionHow to reuse a dialog resource in another project Pin
Electronic7514-Aug-08 2:36
Electronic7514-Aug-08 2:36 
AnswerRe: How to reuse a dialog resource in another project Pin
SandipG 14-Aug-08 2:43
SandipG 14-Aug-08 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.