During validation of an IBAN, of all the IIbanValidationRules most time is spent in the IsMatchingStructureRule validator. To increase performance, we can make use of code generation to generate a custom SwiftPattern class per country in the SwiftRegistryProvider, in which the actual pattern validation is unrolled. This provides a significant performance increase as we no longer have to flow through the general purpose pattern validator, avoiding all the loops and branching.
Performance gains varies per .NET runtime and per country pattern, but goes as high as ~75% and at least ~25%.
Note:
Loop unrolling throws (on generation) for non-fixed length patterns. This is not an issue atm. because no IBAN defined in SWIFT registry is currently of variable length, even though the spec accounts for it.
The WikipediaRegistryProvider has NOT been updated to receive the same treatment.
During validation of an IBAN, of all the
IIbanValidationRule
s most time is spent in theIsMatchingStructureRule
validator. To increase performance, we can make use of code generation to generate a customSwiftPattern
class per country in theSwiftRegistryProvider
, in which the actual pattern validation is unrolled. This provides a significant performance increase as we no longer have to flow through the general purpose pattern validator, avoiding all the loops and branching.Performance gains varies per .NET runtime and per country pattern, but goes as high as ~75% and at least ~25%.
Note:
WikipediaRegistryProvider
has NOT been updated to receive the same treatment.