Optimized version of LinkBuilder.slash() method for identifiers #1381
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 onEntityLinks.linkForItemResource
level.