JeremySkinner/FluentValidation — pull request #35 by nevaenuf (2014-06-24 11:10:16+00:00)
Title: Performance improvement with PropertyName.SplitPascalCase

In PropertyRule, when DisplayName returns null, i.e. when DisplayAttributes are not used, then the PropertyName.SplitPascalCase method is called. This method uses a Regex to add a space before every Capital Letter. I'm using FluentValidation in a way where validation logic may be called over a million times. By caching the property's display name in a local variable, additional calls to the Regex are avoided. This significantly improves performance across that many records.

Also, the DefaultNameResolver could benefit from a caching strategy as well. By caching the memberInfo with the derived name, reflection over the display name attributes is only required once. Since this is an extensibility point, and the caching strategy can be plugged in, I'll include it in a separate pull request.