mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use asset name as key for vector image check caching (#46421)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46421 Changelog: [Internal] Avoid using the Context as a cache key, using only the asset name. Reviewed By: Abbondanzo Differential Revision: D62445718 fbshipit-source-id: 4161e6ef1bbc396c8ab815cdc0362159411f6a68
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f41af55958
commit
199d194c46
+2
-10
@@ -19,7 +19,7 @@ import org.xmlpull.v1.XmlPullParser
|
||||
@ThreadSafe
|
||||
public class ResourceDrawableIdHelper private constructor() {
|
||||
private val resourceDrawableIdMap: MutableMap<String, Int> = HashMap()
|
||||
private val vectorDrawableCheckCache: MutableMap<Context, MutableMap<String, Boolean>> = HashMap()
|
||||
private val vectorDrawableCheckCache: MutableMap<String, Boolean> = HashMap()
|
||||
|
||||
@Synchronized
|
||||
public fun clear() {
|
||||
@@ -65,15 +65,7 @@ public class ResourceDrawableIdHelper private constructor() {
|
||||
}
|
||||
|
||||
public fun isVectorDrawable(context: Context, name: String): Boolean {
|
||||
val cachedResult = vectorDrawableCheckCache[context]?.get(name);
|
||||
if (cachedResult != null) {
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
|
||||
val result = getOpeningXmlTag(context, name) == "vector"
|
||||
vectorDrawableCheckCache.getOrPut(context, { HashMap() }).put(name, result)
|
||||
return result
|
||||
return vectorDrawableCheckCache.getOrPut(name, { getOpeningXmlTag(context, name) == "vector" })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user