Skip to content

Commit dfdf0d4

Browse files
authored
Merge pull request #64 from 1c-syntax/feature/optimizeRead
убрал дублированное хранение
2 parents e6ad473 + 206b748 commit dfdf0d4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/com/github/_1c_syntax/bsl/supconf/ParseSupportData.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static Map<String, SupportVariant> readSimple(Path path) {
7676
var rootPath = getRootPathByParentConfigurations(path);
7777
var supportMap = SUPPORT_SIMPLE_MAPS.get(rootPath);
7878
if (supportMap == null && path.toFile().exists()) {
79-
readFile(path, rootPath);
79+
readFile(path, rootPath, false);
8080
supportMap = SUPPORT_SIMPLE_MAPS.get(rootPath);
8181
}
8282

@@ -97,7 +97,7 @@ public static Map<String, Map<SupportConfiguration, SupportVariant>> readFull(Pa
9797
var rootPath = getRootPathByParentConfigurations(path);
9898
var supportMap = SUPPORT_MAPS.get(rootPath);
9999
if (supportMap == null && path.toFile().exists()) {
100-
readFile(path, rootPath);
100+
readFile(path, rootPath, true);
101101
supportMap = SUPPORT_MAPS.get(rootPath);
102102
}
103103

@@ -125,17 +125,19 @@ public static SupportVariant getSupportVariantByMDO(String uuid, Path path) {
125125
return SupportVariant.NONE;
126126
}
127127

128-
private void readFile(Path pathToBinFile, Path rootPath) {
129-
LOGGER.debug("Чтения файла поставки ParentConfigurations.bin");
128+
private void readFile(Path pathToBinFile, Path rootPath, boolean fullRead) {
129+
LOGGER.debug("Чтения файла поставки ParentConfigurations.bin, полное чтение = " + fullRead);
130130

131131
try {
132132
var supportMap = read(pathToBinFile);
133-
SUPPORT_MAPS.put(rootPath, supportMap);
134-
135-
Map<String, SupportVariant> result = new HashMap<>();
136-
supportMap.forEach((String uuid, Map<SupportConfiguration, SupportVariant> supportVariantMap)
137-
-> result.put(uuid, SupportVariant.max(supportVariantMap.values())));
138-
SUPPORT_SIMPLE_MAPS.put(rootPath, result);
133+
if(fullRead) {
134+
SUPPORT_MAPS.put(rootPath, supportMap);
135+
} else {
136+
Map<String, SupportVariant> result = new HashMap<>();
137+
supportMap.forEach((String uuid, Map<SupportConfiguration, SupportVariant> supportVariantMap)
138+
-> result.put(uuid, SupportVariant.max(supportVariantMap.values())));
139+
SUPPORT_SIMPLE_MAPS.put(rootPath, result);
140+
}
139141
} catch (FileNotFoundException | NumberFormatException exception) {
140142
LOGGER.error(
141143
String.format("Ошибка чтения файла %s", pathToBinFile.toFile()));

0 commit comments

Comments
 (0)