Cache binding lookups for single bean providers #45
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.
Previously every call to
provider.get()
for a Sisu-managedProvider<T>
resulted in a new binding lookup.These extra lookups are unnecessary because Sisu will automatically update live lookups as injectors come and go. This is done to support dynamic maps/lists of beans, but it does mean we can cache binding lookups and re-use them for single providers as long as we only get instances via
BeanEntry.getProvider().get()
.Note: we can't use
BeanEntry.getValue()
when re-using binding lookups because it caches the instance, whereas here we always want to return a fresh bean instance.