Closed drieseng closed 5 years ago
@JamesNK Do you only ever intend to use the first parameter transformer? In DefaultLinkGenerator.CreateTemplateBinder(RouteEndpoint endpoint)
we only pass the first one to the TemplateBinder ctor.
Also, why not pass the constraints and transformer(s) separately to the TemplateBinder ctor? Right now, we do the work of extracting them from the list of parameter policies twice.
Do you only ever intend to use the first parameter transformer?
Yes, for simplicity.
Also, why not pass the constraints and transformer(s) separately to the TemplateBinder ctor? Right now, we do the work of extracting them from the list of parameter policies twice.
It is a public constructor. If additional usages of policies in the future then the constructor would need to change.
@rynowak @JamesNK We're merging Routing today into aspnet/AspNetCore. If you can merge this in the next 30 minutes or so, we can bring this along. Otherwise, you'll have to open a new PR against https://github.com/aspnet/AspNetCore.
Improves performance and reduce allocations in TemplateBinder ctors:
Result:
Benchmark is available here.