Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized version of LinkBuilder.slash() method for identifiers #1381

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mst-avaleo
Copy link

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.

@pivotal-issuemaster
Copy link

@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.

@pivotal-issuemaster
Copy link

@mst-avaleo Thank you for signing the Contributor License Agreement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants