RUM-7740: Extract drawable key generation from ResourcesLRUCache#3279
Merged
Conversation
… a dedicated class Removes the unsafe `as? ResourcesLRUCache` downcast in `BitmapCachesManager.generateResourceKeyFromDrawable` by separating key generation into its own abstraction. Introduces `DrawableKeyGenerator` interface and `ResourceDrawableKeyGenerator` implementation, which now holds all the prefix/hash logic previously embedded in `ResourcesLRUCache`. `BitmapCachesManager` accepts a `DrawableKeyGenerator` as an injected dependency, eliminating the need to know about the concrete cache type.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
@codex review |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3279 +/- ##
===========================================
- Coverage 71.68% 71.53% -0.15%
===========================================
Files 942 943 +1
Lines 34811 34814 +3
Branches 5899 5898 -1
===========================================
- Hits 24954 24903 -51
- Misses 8233 8274 +41
- Partials 1624 1637 +13
🚀 New features to boost your workflow:
|
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
hamorillo
marked this pull request as ready for review
March 23, 2026 10:52
0xnm
previously approved these changes
Mar 23, 2026
ambushwork
previously approved these changes
Mar 23, 2026
ambushwork
approved these changes
Mar 23, 2026
0xnm
approved these changes
Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Removes the unsafe
as? ResourcesLRUCachedowncast inBitmapCachesManager.generateResourceKeyFromDrawableby extracting keygeneration into a dedicated
DrawableKeyGeneratorinterface with aResourceDrawableKeyGeneratorimplementation.BitmapCachesManagernowaccepts a
DrawableKeyGeneratoras an injected dependency, eliminatingthe need to know about the concrete cache type.
Motivation
The original code performed a silent safe-cast to
ResourcesLRUCacheinside
BitmapCachesManager, meaning any non-ResourcesLRUCacheimplementation of
Cache<String, ByteArray>would silently returnnullfrom
generateResourceKeyFromDrawable. The new design separates storagefrom key generation and makes the dependency explicit and mockable in tests.
Additional Notes
No public API surface changes.
Review checklist (to be filled by reviewers)