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

Combine BindingGraphFactory.Resolver's caching logic into a single location. #4414

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

copybara-service[bot]
Copy link

Combine BindingGraphFactory.Resolver's caching logic into a single location.

Currently, there are two places where we try to cache a binding:

Resolver#resolve(Key) checks if there's a previously resolved binding for the given key in an ancestor resolver.
Resolver#lookUpBindings(Key) checks if a resolved binding should be owned by an ancestor component (e.g. because its scoped).
Note that these two checks are slightly different. Case 1 only depends on the Key and is iteration-order dependent since it depends on whether the key has already been resolved in a ancestor binding. Case 2 depends on the binding rather than just the key (which is why it occurs at the end of lookUpBindings) and tries to determine if a binding could be resolved in a parent component (e.g. based on the scope or which component installs the module). Thus, case 2 may cache bindings that case 1 doesn't in cases where we know a binding is resolvable in an ancestor but hasn't yet been resolved (e.g. due to order or just because nothing actually requests it).

In any case, this CL consolidates that logic into a single place. This should make it easier to extract the caching logic later from the intermediate graph creation.

RELNOTES=N/A

…cation.

Currently, there are two places where we try to cache a binding:

Resolver#resolve(Key) checks if there's a previously resolved binding for the given key in an ancestor resolver.
Resolver#lookUpBindings(Key) checks if a resolved binding should be owned by an ancestor component (e.g. because its scoped).
Note that these two checks are slightly different. Case 1 only depends on the Key and is iteration-order dependent since it depends on whether the key has already been resolved in a ancestor binding. Case 2 depends on the binding rather than just the key (which is why it occurs at the end of lookUpBindings) and tries to determine if a binding could be resolved in a parent component (e.g. based on the scope or which component installs the module). Thus, case 2 may cache bindings that case 1 doesn't in cases where we know a binding is resolvable in an ancestor but hasn't yet been resolved (e.g. due to order or just because nothing actually requests it).

In any case, this CL consolidates that logic into a single place. This should make it easier to extract the caching logic later from the intermediate graph creation.

RELNOTES=N/A
PiperOrigin-RevId: 668007196
@copybara-service copybara-service bot merged commit de59d69 into master Aug 27, 2024
@copybara-service copybara-service bot deleted the test_661957107 branch August 27, 2024 15:59
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.

1 participant