Inside the compiler
#1

I was looking at a callback and wondering if it being so long would be effecting performance, particularly in cases where the callback is called frequently. The best way I can get my question understood is to create an example.

Will the processor skip instantly over irrelevant bracketed code?



Would ( in theory ) the example on the right cause the callback to be processed any faster?
or would the compiler see these as the same?


The reason I am wondering is because if the processor is taking time to regularly skip over large sections of code that are rarely used, then it would be worth moving that large rarely used code.
Reply
#2

another example, and perhaps a deeper question relating to switch statements

would it be optimal to put longer cases at the end of the statement?
Reply
#3

I think the example on the left is actually faster, because it executes the code right away, but on the right it has to call a function first.

If resultid is 4, then it will skip cases 1,2 and 3 anyway, so I don't think it makes much difference.
Reply
#4

You seem to misunderstand my question.

I'm interested in if a long case of code will make the other cases slower
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)