Improve performance of route matching
While looking at some flamegraphs of API requests, I noticed several times that GrapePathHelpers::NamedRouteMatcher#route_match?
was one of the methods with the highest durations.
It's not that bad all the time, but even on good runs it's still one of the top ones:
This method is used to generate API links, specially these _links
that are always present in our responses:
This MR attempts to optimize this by stringifying the arguments only once.
This also improves the uses_segments_in_path_helper?
check by using the memoized required_helper_segments
in DecoratedRoute
Edited by Heinrich Lee Yu