mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cache ReplacePathToMacroMap
This commit is contained in:
+16
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.application.options.PathMacrosCollector;
|
||||
@@ -30,6 +30,9 @@ public class BasePathMacroManager extends PathMacroManager {
|
||||
|
||||
private PathMacrosImpl myPathMacros;
|
||||
|
||||
private ReplacePathToMacroMap myReplacePathToMacroMap;
|
||||
private long myPathMacrosModificationCount;
|
||||
|
||||
public BasePathMacroManager(@Nullable PathMacros pathMacros) {
|
||||
myPathMacros = (PathMacrosImpl)pathMacros;
|
||||
}
|
||||
@@ -80,12 +83,22 @@ public class BasePathMacroManager extends PathMacroManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ReplacePathToMacroMap getReplacePathMap() {
|
||||
protected synchronized ReplacePathToMacroMap getReplacePathMap() {
|
||||
PathMacrosImpl pathMacros = getPathMacros();
|
||||
|
||||
long pathMacrosModificationCount = pathMacros.getModificationCount();
|
||||
if (myReplacePathToMacroMap != null && pathMacrosModificationCount == myPathMacrosModificationCount) {
|
||||
return myReplacePathToMacroMap;
|
||||
}
|
||||
|
||||
ReplacePathToMacroMap result = new ReplacePathToMacroMap();
|
||||
getPathMacros().addMacroReplacements(result);
|
||||
pathMacros.addMacroReplacements(result);
|
||||
for (Map.Entry<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
|
||||
result.addMacroReplacement(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
||||
myReplacePathToMacroMap = result;
|
||||
myPathMacrosModificationCount = pathMacrosModificationCount;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user