Premature optimization is the root of all evil.
For all of we programmers,we should always remember that "Premature optimization is the root of all evil". (Ref)
When again,I come back to the 'Data Structure and Algorithm',following the algorithms that the .net provides,using the '.net reflector',I realise that I was too much care about something(for i am not work strict to memory and CPU circle limits).
The issue I posted "Would it cost any extra performance if multiple invoke methods that are overload?" on the forum "Stackoverflow" shows the issue that confused me before.
That issue comes from .net ArrayList class,such as the code below:
1 public static void Copy(Array sourceArray, Array destinationArray, int length) 2 { 3 if (sourceArray == null) 4 { 5 throw new ArgumentNullException("sourceArray"); 6 } 7 if (destinationArray == null) 8 { 9 throw new ArgumentNullException("destinationArray"); 10 } 11 Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, false); 12 } 13 14 15 16
it actually calls
1 Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, false);
1 internal static extern void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable); 2 3 4
as it is obvious.
The method call between themselves can be 'inlined',or the opitimized by jitter.
And remember that "Premature optimization is the root of all evil". Take much time to think about our own algorithms.