Click here to Skip to main content
15,900,724 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Optimisation challenge... Pin
Aescleal30-Jun-10 0:24
Aescleal30-Jun-10 0:24 
GeneralRe: Optimisation challenge... Pin
KarstenK30-Jun-10 3:48
mveKarstenK30-Jun-10 3:48 
GeneralRe: Optimisation challenge... Pin
Aescleal30-Jun-10 4:14
Aescleal30-Jun-10 4:14 
GeneralRe: Optimisation challenge... Pin
KarstenK30-Jun-10 4:38
mveKarstenK30-Jun-10 4:38 
GeneralRe: Optimisation challenge... Pin
MarkB77730-Jun-10 10:52
MarkB77730-Jun-10 10:52 
GeneralRe: Optimisation challenge... Pin
Aescleal30-Jun-10 11:17
Aescleal30-Jun-10 11:17 
AnswerRe: Optimisation challenge... Pin
KarstenK30-Jun-10 3:50
mveKarstenK30-Jun-10 3:50 
AnswerRe: Optimisation challenge... [modified] Pin
Chris Losinger30-Jun-10 4:19
professionalChris Losinger30-Jun-10 4:19 
you could probably _snprintf all the parts into the output string.

alternately, if you want to improve performance, take a look at all those strcat calls. each one of those does a scan of the output string, looking for the end.

strcpy(_acLine, pcH1);
strcat(_acLine, acBuff1);  <-- full pass over _acLine
strcat(_acLine, pcH2);  <-- another full pass over _acLine
strcat(_acLine, acBuff2);  <-- another full pass over _acLine


but if you know the lengths of pcH1, acBuff1, pch2 and acBuff2, you will know where the end of _acLine should be after each concatenation.

so you can simply memcpy the substrings directly where they should be:

memcpy(_acLine, pcH1, len_pcH1);
memcpy(_acLine + len_pcH1, acBuff1, len_buff1 );
memcpy(_acLine + len_pcH1 + len_buff1, pcH2, len_pcH2 );
memcpy(_acLine + len_pcH1 + len_buff1 + len_pcH2, acBuff2, len_buff2 );
acLine[len_pcH1 + len_buff1 + len_pcH2 + buff2] = 0;


and if you know the length of acBuff1 and acBuff2 then maybe you could do this:
memcpy(_acLine, pcH1, len_pcH1);
memcpy(_acLine + len_pcH1, lcd_String(dV1), len_buff1 );
memcpy(_acLine + len_pcH1 + len_buff1, pcH2, len_pcH2 );
memcpy(_acLine + len_pcH1 + len_buff1 + len_pcH2, lcd_String(dV2), len_buff2 );
acLine[len_pcH1 + len_buff1 + len_pcH2 + buff2] = 0;

... and get rid of those first two strcpys, too.

or, if you want to get really low-level, just concat the strings yourself. something like:
LPSTR pOut = _acLine;
while (*pcH1) *pOut++=*pcH1++;
while (*acBuff1) *pOut++=*acBuff1++;
while (*pcH2) *pOut++=*pcH2++;
while (*acBuff2) *pOut++=*acBuff2++;
*pOut = 0;

image processing toolkits | batch image processing
modified on Wednesday, June 30, 2010 10:25 AM

GeneralRe: Optimisation challenge... Pin
MarkB77730-Jun-10 11:01
MarkB77730-Jun-10 11:01 
GeneralRe: Optimisation challenge... Pin
Chris Losinger30-Jun-10 11:41
professionalChris Losinger30-Jun-10 11:41 
GeneralRe: Optimisation challenge... Pin
MarkB77730-Jun-10 12:00
MarkB77730-Jun-10 12:00 
QuestionWin32_ScheduledJob Pin
Jayapal Chandran29-Jun-10 23:36
Jayapal Chandran29-Jun-10 23:36 
Questionscollbar in CStatic Pin
kk.tvm29-Jun-10 23:28
kk.tvm29-Jun-10 23:28 
AnswerRe: scollbar in CStatic Pin
Cedric Moonen29-Jun-10 23:37
Cedric Moonen29-Jun-10 23:37 
GeneralRe: scollbar in CStatic Pin
kk.tvm29-Jun-10 23:57
kk.tvm29-Jun-10 23:57 
GeneralRe: scollbar in CStatic Pin
Cedric Moonen30-Jun-10 0:13
Cedric Moonen30-Jun-10 0:13 
GeneralRe: scollbar in CStatic Pin
kk.tvm30-Jun-10 0:39
kk.tvm30-Jun-10 0:39 
GeneralRe: scollbar in CStatic Pin
Cedric Moonen30-Jun-10 1:06
Cedric Moonen30-Jun-10 1:06 
GeneralRe: scollbar in CStatic Pin
kk.tvm30-Jun-10 1:21
kk.tvm30-Jun-10 1:21 
QuestionMessage Removed Pin
29-Jun-10 22:34
learningvisualc29-Jun-10 22:34 
AnswerRe: Detecting sim card reader Pin
LloydA11130-Jun-10 1:16
LloydA11130-Jun-10 1:16 
Questionconditional menu Pin
josip cagalj29-Jun-10 22:27
josip cagalj29-Jun-10 22:27 
AnswerRe: conditional menu Pin
Richard MacCutchan30-Jun-10 1:34
mveRichard MacCutchan30-Jun-10 1:34 
AnswerRe: conditional menu Pin
KarstenK30-Jun-10 3:46
mveKarstenK30-Jun-10 3:46 
GeneralRe: conditional menu Pin
josip cagalj30-Jun-10 3:50
josip cagalj30-Jun-10 3:50 

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.