-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Possible optimization in UrlResource #25531
Comments
This turns out to be straightforward so that it can even be considered for 5.2.9. One exception: |
Great. In my tests I stored the original input in a field as well. That way it could always be lazy. |
Indeed, but at the expense of an additional field sticking around for any kind of |
Closes spring-projectsgh-25531 (cherry picked from commit 96a4e11)
UrlResource
computes acleanedUrl
in its constructor, but only uses it in a small number of methods (e.g.hashCode()
). It has someString
manipulations in it that can be expensive, so it might make sense to compute it lazily.Some benchmarks (instantiate a
FileUrlResource
and check if itexists()
):I think the fact that the median comparison is much more dramatic is probably because of garbage collection, which is quite noisy, and would be more common in the default case.
Spring Boot computes quite a few of these
FileUrlResources
on startup as it searches forapplication.properties
files. The difference is just about noticeable (a few milliseconds on startup, and fewer GC failures).The text was updated successfully, but these errors were encountered: