RenderTheme: increase cache size

See: https://github.com/mapsforge/mapsforge/pull/1369
This commit is contained in:
Emux 2022-12-02 10:13:25 +02:00
parent b4014eec64
commit 26d63a7606
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3

View File

@ -39,7 +39,7 @@ import java.util.Map;
public class RenderTheme implements IRenderTheme { public class RenderTheme implements IRenderTheme {
static final Logger log = LoggerFactory.getLogger(RenderTheme.class); static final Logger log = LoggerFactory.getLogger(RenderTheme.class);
private static final int MATCHING_CACHE_SIZE = 512; private static final int MATCHING_CACHE_SIZE = 8192;
private final float mBaseTextSize; private final float mBaseTextSize;
private final int mMapBackground; private final int mMapBackground;
@ -51,19 +51,19 @@ public class RenderTheme implements IRenderTheme {
private final Map<String, String> mTransformBackwardKeyMap, mTransformForwardKeyMap; private final Map<String, String> mTransformBackwardKeyMap, mTransformForwardKeyMap;
private final Map<Tag, Tag> mTransformBackwardTagMap, mTransformForwardTagMap; private final Map<Tag, Tag> mTransformBackwardTagMap, mTransformForwardTagMap;
class RenderStyleCache { static class RenderStyleCache {
final int matchType; final int matchType;
final LRUCache<MatchingCacheKey, RenderStyleItem> cache; final LRUCache<MatchingCacheKey, RenderStyleItem> cache;
final MatchingCacheKey cacheKey; final MatchingCacheKey cacheKey;
/* temporary matching instructions list */ /* temporary matching instructions list */
final ArrayList<RenderStyle> instructionList; final List<RenderStyle> instructionList;
RenderStyleItem prevItem; RenderStyleItem prevItem;
public RenderStyleCache(int type) { public RenderStyleCache(int type) {
cache = new LRUCache<MatchingCacheKey, RenderStyleItem>(MATCHING_CACHE_SIZE); cache = new LRUCache<>(MATCHING_CACHE_SIZE);
instructionList = new ArrayList<RenderStyle>(4); instructionList = new ArrayList<>(4);
cacheKey = new MatchingCacheKey(); cacheKey = new MatchingCacheKey();
matchType = type; matchType = type;
} }
@ -73,7 +73,7 @@ public class RenderTheme implements IRenderTheme {
} }
} }
class RenderStyleItem { static class RenderStyleItem {
RenderStyleItem next; RenderStyleItem next;
int zoom; int zoom;
RenderStyle[] list; RenderStyle[] list;