[Mono-dev] PATCH for String.StartsWith(string, StringComparison)

Paolo Molaro lupus at ximian.com
Fri Feb 3 04:50:27 EST 2006


On 02/03/06 Atsushi Eno wrote:
> I agree on "faster" part, but considering the heaviness of string
> comparison itself the difference is so trivial ;-)

This is no excuse.
If string comparison is slow, it needs to be made faster, not slower.
String operations are _fundamental_ in many apps and every mono contributor
needs to be aware of performance issues in such a core part.
The code was ugly, so it's good to fix the style and it's possible to
have nice code that's fast.
In this particular case there is also one more consideration to make.
The committed code is only marginally slower so most of the time it
wouldn't be a big deal. But the other property  of the original version
is that the JIT will be able to optimize it away when the method is
called with a constant StringComparison value, which happens most of
the time. This is much more difficult with the committed version.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list