feat: calculate path substitutions in `RestMethodInfo` by TimothyMakkison · Pull Request #1897 · reactiveui/refit

Parse the url target inside RestMethodInfo, removing the use of regex on function calls.

Re attempt at #1730. Turns out the additional allocations were caused by line 829 creating a closure. Looking at the lowered code C# always created the linq closure, even when round tripping was never used 🤔

In future I could optimise round trip to not use string.Split, either manually splitting or using Span.Split

Benchmarks (on battery power)

Method Mean Error StdDev Median Gen0 Allocated
ConstantRouteAsync 9.332 us 0.6444 us 1.8999 us 9.479 us 0.2899 2.71 KB
DynamicRouteAsync 5.284 us 0.2704 us 0.7449 us 4.957 us 0.3052 3 KB
ComplexDynamicRouteAsync 5.091 us 0.4201 us 1.2387 us 4.433 us 0.3662 3.41 KB
ObjectRequestAsync 5.942 us 0.1163 us 0.2504 us 5.834 us 0.4730 4.41 KB
ComplexRequestAsync 18.005 us 0.4408 us 1.2359 us 17.392 us 1.1292 10.44 KB

Old benchmarks

Method Mean Error StdDev Gen0 Allocated
ConstantRouteAsync 2.072 us 0.0110 us 0.0097 us 0.2937 2.71 KB
DynamicRouteAsync 2.783 us 0.0259 us 0.0202 us 0.3319 3.07 KB
ComplexDynamicRouteAsync 4.060 us 0.0226 us 0.0200 us 0.4044 3.78 KB
ObjectRequestAsync 4.954 us 0.0295 us 0.0262 us 0.4807 4.48 KB
ComplexRequestAsync 14.455 us 0.0686 us 0.0642 us 1.1597 10.67 KB