Click here to Skip to main content
15,910,787 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerCrosspost Pin
Richard MacCutchan19-Jun-10 21:28
mveRichard MacCutchan19-Jun-10 21:28 
QuestionWMI getting IP-Address [modified] Pin
Marcel Vogt19-Jun-10 4:23
Marcel Vogt19-Jun-10 4:23 
AnswerSuggestion Pin
Baltoro19-Jun-10 8:52
Baltoro19-Jun-10 8:52 
GeneralRe: Suggestion Pin
Marcel Vogt19-Jun-10 8:59
Marcel Vogt19-Jun-10 8:59 
GeneralRe: Suggestion Pin
Baltoro19-Jun-10 9:16
Baltoro19-Jun-10 9:16 
AnswerRe: WMI getting IP-Address Pin
Luc Pattyn19-Jun-10 9:26
sitebuilderLuc Pattyn19-Jun-10 9:26 
AnswerRe: WMI getting IP-Address Pin
Hristo-Bojilov20-Jun-10 3:44
Hristo-Bojilov20-Jun-10 3:44 
QuestionWhich is faster? Pin
Code-o-mat19-Jun-10 0:48
Code-o-mat19-Jun-10 0:48 
Hey folks!

I was just wondering, which of these would be faster:
RECT R1, R2;
POINT Offset;
...
R1 = R2;
R1.left    += Offset.x;
R1.right   += Offset.x;
R1.top     += Offset.y;
R1.bottom  += Offset.y;

or
RECT R1, R2;
POINT Offset;
...
R1.left    = R2.left   + Offset.x;
R1.right   = R2.right  + Offset.x;
R1.top     = R2.top    + Offset.y;
R1.bottom  = R2.bottom + Offset.y;

As a "sub question of this", would this:
R1.left    += Offset.x;
R1.right   += Offset.x;
R1.top     += Offset.y;
R1.bottom  += Offset.y;

be faster than this:
R1.left    += Offset.x;
R1.top     += Offset.y;
R1.right   += Offset.x;
R1.bottom  += Offset.y;

? I mean, in the first version when the first addition is done Offset.x is already loaded into one of the registers so the second addition needs less memory access, while in the second version, it would need to retrieve Offset.y to do the addition, then retrieve Offset.x again and then Offset.y again. In the first version it has to retrieve both Offset.x and Offset.y only once during the 4 additions, so that's half the memory access from Offset's point of view. Right? If so, I also wonder if the compiler is smart enough to change the order of these to produce a more speed optimized code (i personally highly doubt this).
Thanks for any sharing of thoughts. Smile | :)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers don't kill programs, users kill programs <
> "It doesn't work, fix it" does not qualify as a bug report. <

AnswerRe: Which is faster? Pin
Aescleal19-Jun-10 0:55
Aescleal19-Jun-10 0:55 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 1:00
Code-o-mat19-Jun-10 1:00 
GeneralRe: Which is faster? [modified] Pin
Code-o-mat19-Jun-10 5:16
Code-o-mat19-Jun-10 5:16 
GeneralRe: Which is faster? Pin
Aescleal19-Jun-10 6:10
Aescleal19-Jun-10 6:10 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 6:12
Code-o-mat19-Jun-10 6:12 
GeneralRe: Which is faster? Pin
Aescleal19-Jun-10 6:36
Aescleal19-Jun-10 6:36 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 6:53
Code-o-mat19-Jun-10 6:53 
GeneralRe: Which is faster? Pin
CPallini19-Jun-10 8:34
mveCPallini19-Jun-10 8:34 
GeneralRe: Which is faster? Pin
Member 419459319-Jun-10 15:54
Member 419459319-Jun-10 15:54 
GeneralRe: Which is faster? Pin
Aescleal19-Jun-10 23:15
Aescleal19-Jun-10 23:15 
AnswerRe: Which is faster? Pin
Luc Pattyn19-Jun-10 1:04
sitebuilderLuc Pattyn19-Jun-10 1:04 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 5:49
Code-o-mat19-Jun-10 5:49 
GeneralRe: Which is faster? Pin
Luc Pattyn19-Jun-10 5:55
sitebuilderLuc Pattyn19-Jun-10 5:55 
AnswerRe: Which is faster? Pin
CPallini19-Jun-10 1:08
mveCPallini19-Jun-10 1:08 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 1:13
Code-o-mat19-Jun-10 1:13 
GeneralRe: Which is faster? Pin
Druuler19-Jun-10 5:54
Druuler19-Jun-10 5:54 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 5:57
Code-o-mat19-Jun-10 5:57 

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.