- Joined
- Jul 6, 2005
- Messages
- 63,203
- Likes received
- 5,553
- Thanks received
- 1,318
bogeyman said:Do you like to obfuscate your code to show how clever you are?
No. But I do use profiler to identify hot places that use most of CPU (that's how I ended up digging into Microsoft source). In such cases I am not shy to make code less maintainable if I can achieve serious speed up. Given number of people who use .NET framework and basic nature of Sort operation it should obviously be optimised for speed rather than programmer's convinience.
For example I've got a perl script that would generate optimised code for some different situations, to maintain it I just need to maintain single piece of code plus script, the end code may not be readable but its extremely fast - this is what is required from any base library that actually ships without source in the first place.
The most efficient variable swap would load such vars into registers and does a very quick swap, this is particularly good if along the execution path such variables will already have to be loaded into registers, so it means such swap can be done very nicely indeed with zero overhead. Of course this function should have been written in low level .NET assembly rather than C# - its sorting, it has got to be extremely fast not just algorithmically but also taking advantage of very good implementation. If I know it then people employed by Microsoft to do such a basic thing should know it 10 times better than me.
Last edited:
16:31

