perf: DirFilterEvents.findDirRpos: single map access on fast path
This commit is contained in:
parent
b3e8cc22cf
commit
d02e9f697a
|
@ -113,8 +113,12 @@ public enum DirFilterEvents implements UserResourceEvents.Open, UserResourceEven
|
|||
CachedPackState state = MetaCache.getState(MetaCache.getKeyByPack(pack));
|
||||
var cache = state.cachedDirRPOs();
|
||||
|
||||
// This is outside computeIfAbsent because it could cause modification of the map, which is unsupported within it
|
||||
if (cache.containsKey(path)) return cache.get(path);
|
||||
{
|
||||
// This is outside computeIfAbsent because it could cause modification of the map, which is unsupported within it
|
||||
List<DirRpo> cached = cache.get(path);
|
||||
if (cached != null) return cached;
|
||||
}
|
||||
|
||||
List<DirRpo> parentRPOs = findDirRpos(pack, parent(path));
|
||||
synchronized (cache) { // This is synchronized as multiple resources might be accessed at the same time, potentially causing a CME here
|
||||
return cache.computeIfAbsent(path, $ -> {
|
||||
|
|
Loading…
Reference in New Issue