String Performance
NHibernate just got a patch that replace this line:
With this:
This is done to increase perfromance in a slow part of the code. Looking at this, can you spot the reason for the performance increase between the two?
ToLower() will create a new string (which require memory allocation) use if for a single call and discard it (which means the GC now has to collect it). The second approach doesn't create temporary objects and does not require memory allocation for potentially large object.
Comments
Actually, StringComparison.OrdinalIgnoreCase is a faster alternative to this, as it uses the Unicode values of the chars. InvariantCulture shouldn't even be used, because it doesn't take any useful culture into account (we would be using CurrentCulture for this), and because it is slower than Ordinal.
The problem is that Ordinal does not exist on the 1.1 framework.
Comment preview