Click here to Skip to main content
15,881,413 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Performance problem with my FindOneOf function Pin
Stuart Dootson22-Jun-09 9:34
professionalStuart Dootson22-Jun-09 9:34 
GeneralRe: Performance problem with my FindOneOf function Pin
Ivan Ivanov 8322-Jun-09 11:28
Ivan Ivanov 8322-Jun-09 11:28 
AnswerRe: Performance problem with my FindOneOf function Pin
Roger Stoltz22-Jun-09 9:22
Roger Stoltz22-Jun-09 9:22 
GeneralRe: Performance problem with my FindOneOf function Pin
Ivan Ivanov 8322-Jun-09 10:59
Ivan Ivanov 8322-Jun-09 10:59 
GeneralRe: Performance problem with my FindOneOf function Pin
Roger Stoltz22-Jun-09 21:39
Roger Stoltz22-Jun-09 21:39 
GeneralRe: Performance problem with my FindOneOf function [modified] Pin
Ivan Ivanov 8324-Jun-09 1:45
Ivan Ivanov 8324-Jun-09 1:45 
GeneralRe: Performance problem with my FindOneOf function Pin
Roger Stoltz24-Jun-09 4:16
Roger Stoltz24-Jun-09 4:16 
GeneralRe: Performance problem with my FindOneOf function [modified] Pin
Ivan Ivanov 8325-Jun-09 1:25
Ivan Ivanov 8325-Jun-09 1:25 
Roger Stoltz wrote:
It would be really nice to write it in C/C++ in such way that the compiler would generate the same tight code. That would make it more portable.


YES! Not only more portable, if the code is in C/C++ the compiler will have a far better chance to build-in the entire inline function! Wink | ;)
All of my functions are declared inline, but since I use inline assembly inside them, I make explicit use of specific registers, thus not allowing the compiler to use the currently free ones! Wink | ;) In effect the compiler couldn't build-in the function, but compiles it as a normal procedure and CALLs it with all stack operations necessary. Fortunately the runtime library is just the same story! Big Grin | :-D It's full of CALLs and PUSH-POPs Smile | :) , for instance: before CString::FindOneOf gets ready to call of strspn it passes through whole bunch of them!
And I already had some issues using inline assembly, for example: when I installed a new version of NOD32 and scaned the PC, it detected my test application as unknown virus, obviously it somehow detected the unusual assembly code and alarmed. NOD32 is actually known assembly code analyser, that's probably because the inline assembly is mostly used by virus writers these days. I used the option to send them the EXE for analysis to see that it's not bad at all! Big Grin | :-D

I considered writing my algorithms in C/C++ too great effort (at least for now). A lot of other functions await me to implement them after all. And I'm willing to give them just as much attention as I gave to FindOneOf Smile | :) if necessary. Let me see the entire conception working and then I'll try the "siplusplusing" (I just got this term Big Grin | :-D )

Roger Stoltz wrote:
I'm not aware of any statement in C that would make use of assembly bit manipulation instructions with bit numbers higher than e.g. 31 on a 32-bit system.


Why don't you try to write some yourself? Wink | ;)

//Set bit...
inline void operator [] (void* pBitTable, int index)
{
   __asm
   {
      mov EAX, index
      bts pBitTable, EAX
   }
};

//Test for bit...
inline bool operator [] (void* pBitTable, int index)
{
   __asm
   {
      mov EAX, index
      bt  pBitTable, EAX
      jb  True
      xor EAX, EAX
      jmp Skip
True: mov EAX, 1
Skip:
   }
};


Well these hardly will give better rsults than pure assembly code, but who knows what miracles the compiler/optimizer are capable of! Smile | :) I think there is a GOOD chance for the compiler to build these in 'cause only EAX is named directly and you know it's reserved for the return value and the compiler keeps it free before any call Wink | ;)

(the code above is just to give you the idea Wink | ;) I haven't eaven tested it! But I do think it's a good idea Smile | :) and I'm pretty sure it'll work fine)

modified on Thursday, June 25, 2009 10:44 AM

QuestionXMLHTTP post failed with status code 415 Pin
Ash_VCPP22-Jun-09 3:47
Ash_VCPP22-Jun-09 3:47 
AnswerRe: XMLHTTP post failed with status code 415 Pin
KarstenK22-Jun-09 4:15
mveKarstenK22-Jun-09 4:15 
QuestionTimer on Statusbar Pin
susanne122-Jun-09 3:10
susanne122-Jun-09 3:10 
AnswerRe: Timer on Statusbar Pin
Rajesh R Subramanian22-Jun-09 3:25
professionalRajesh R Subramanian22-Jun-09 3:25 
AnswerRe: Timer on Statusbar Pin
David Crow22-Jun-09 4:05
David Crow22-Jun-09 4:05 
QuestionHow to access element in Multiset by index Pin
alikalik22-Jun-09 3:05
alikalik22-Jun-09 3:05 
AnswerRe: How to access element in Multiset by index Pin
Chris Losinger22-Jun-09 3:13
professionalChris Losinger22-Jun-09 3:13 
GeneralRe: How to access element in Multiset by index Pin
alikalik22-Jun-09 3:30
alikalik22-Jun-09 3:30 
AnswerRe: How to access element in Multiset by index Pin
Sarath C22-Jun-09 3:20
Sarath C22-Jun-09 3:20 
Questionsplit wavefiles programetically Pin
N Vamshi Krishna22-Jun-09 3:04
N Vamshi Krishna22-Jun-09 3:04 
AnswerRe: split wavefiles programetically Pin
Rozis23-Jun-09 6:42
Rozis23-Jun-09 6:42 
QuestionPlease clarify my doubt.... Pin
Rakesh522-Jun-09 2:25
Rakesh522-Jun-09 2:25 
AnswerRe: Please clarify my doubt.... Pin
Stuart Dootson22-Jun-09 2:42
professionalStuart Dootson22-Jun-09 2:42 
QuestionAPI for changing Language for non-Unicode Programs???? Pin
Super Hornet22-Jun-09 1:39
Super Hornet22-Jun-09 1:39 
AnswerRe: API for changing Language for non-Unicode Programs???? Pin
Rajesh R Subramanian22-Jun-09 1:46
professionalRajesh R Subramanian22-Jun-09 1:46 
QuestionRe: API for changing Language for non-Unicode Programs???? Pin
Super Hornet22-Jun-09 1:50
Super Hornet22-Jun-09 1:50 
AnswerRe: API for changing Language for non-Unicode Programs???? Pin
Rajesh R Subramanian22-Jun-09 1:59
professionalRajesh R Subramanian22-Jun-09 1:59 

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.