spring-hateoas
spring-hateoas copied to clipboard
Optimized version of LinkBuilder.slash() method for identifiers
Hi,
I'm looking on performance of following code, since it's used heavily on collection resources for self
links in our projects,
especially when collection is large.
entityLinks.linkForItemResource(Person.class, personId).withSelfRel();
I've found that slash()
method used behind the scene is a quite generic method, which can be used together with URL parts with many path segments and fragments (for example .slash("/segment/segment2#fragment")
). Therefore there's a heavy URL processing in slash() methods used for this case. Though for the identifiers case, it's completely not needed in my opinion. Maybe I'm missing something...
In the PR, I've proposed a solution, where there's a specific slashId()
method meant to be used only for identifiers. This enables to use simpler approach, where the input data doesn't need to be parsed from URL perspective. In result, the change gives around 20% of optimization when testing on EntityLinks.linkForItemResource
level.
@mst-avaleo Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@mst-avaleo Thank you for signing the Contributor License Agreement!