The online racing simulator
Quote from broken :but C becomes 2 times faster than C# in the current case.

The C version will not be two times faster than the C# version. I'm not sure that the C version would be faster at all.

Warning: the stuff below is my own opinion and other people might not agree with me.

Quote :I know that sometimes taking too much time on optimization can just have the opposite impact on your creation, but my simplistic brain tells me that this is quite not the case. And, yes - not 'not quite the case', but indeed 'quite not the case'.

This isn't really a question of optimisation it's a question of having good coding practices. The whole "premature optimisation is the root of all evil" thing is a misquote lazy programmers come out with as an excuse for writing bad code.

There are three kinds of optimisation:
  • Optimisation that comes from good coding practices (like above)
  • Optimisation that comes from having a good design
  • Optimisation that comes from measuring performance and focusing on the slowest areas
Only the third item can be considered a premature optimisation if you do it too early, the first is something you should be thinking about all the time and the second you should be thinking about before you write a line of code. Now all this is not to say that you should sacrifice readability for performance, first and foremost you should write code that's easy to read, but if you are finding it hard to optimise your code while maintaining legibility that would suggest that there is something wrong with your design or your algorithms.

So basically I would not consider the (C/C#) code examples above to be a symptom of premature optimisation, I consider them to be examples of fundamental good coding practice.
Quote from DarkTimes :The C version will not be two times faster than the C# version. I'm not sure that the C version would be faster at all.

Yes, this was just an assumption that I stated as a fact. Didn't really mean to. ;d

Quote from DarkTimes :Warning: the stuff below is my own opinion and other people might not agree with me.

[...]

I agree, and it's exactly what I wanted to say.

Dygear, it's not that I disagree with you completely, but I don't think that such an obvious optimization is something bad either (not that I know more than you in this area).

Of course, this is just my opinion too. I'm saying this in case I sound like I'm stating facts somewhere again.
2

FGED GREDG RDFGDR GSFDG