This change makes the allocation of DataTokens and Values on RouteData
lazy, and elides copies when copying an 'empty' RouteData.
In our current architecture this change will eliminiate 2 * (N + 1)
dictionary allocations/copies per request, where N is the number of routes
processed. In a large system with lots of attribute routes, this number
could be very significant.
For a small MVC site (ModelBinding, Validation, Views) with one route, it
still shows a modest reduction of dictionary allocations without adding
much complexity.
This is the routing part of the fix. MVC will be updated as well
(attribute routing).
As the graph of routers is traversed, routers add themselves to the
current 'path', which unwinds on a failed path.
This mechanism is opt-in. Whoever adds something needs to remove it as
part of cleanup. If a router in the tree doesn't interact with the
.Routers property, then there are no consequences for those that do.
Additionally, fixing #116 as part of the same change. This means that we
create a nested 'RouteData' and then restore it on the way out. This is
simpler than just dealing with the .Routers property in isolation.
This is the routing part of these changes, and just the breaking changes
parts.
Follow-ups will add:
- DataTokens
- Tracking the logical stack of routers