Skip to content

Commit e69b628

Browse files
authored
Merge pull request #441 from 1c-syntax/feature/optimize
Feature/optimize
2 parents a8af664 + f00f3f4 commit e69b628

File tree

13 files changed

+627
-1029
lines changed

13 files changed

+627
-1029
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ build/
1212
/.idea/sonar*
1313

1414
/.idea/misc.xml
15+
Gradle_*.xml

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ dependencies {
5656
// прочее
5757
implementation("commons-io", "commons-io", "2.8.0")
5858
implementation("com.github.1c-syntax", "utils", "0.5.1")
59-
implementation("io.github.1c-syntax", "bsl-common-library", "0.5.0")
60-
implementation("io.github.1c-syntax", "supportconf", "0.12.1") {
59+
implementation("io.github.1c-syntax", "bsl-common-library", "0.5.1")
60+
implementation("io.github.1c-syntax", "supportconf", "0.13.1") {
6161
exclude("io.github.1c-syntax", "bsl-common-library")
6262
}
6363

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/RoleData.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo.storage;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
2323

2424
import com.github._1c_syntax.bsl.mdo.support.RoleRight;
2525
import com.github._1c_syntax.bsl.reader.MDOReader;
26+
import com.github._1c_syntax.utils.GenericInterner;
2627
import lombok.Builder;
2728
import lombok.Builder.Default;
2829
import lombok.EqualsAndHashCode;
@@ -46,6 +47,7 @@
4647
public class RoleData {
4748

4849
public static final RoleData EMPTY = RoleData.builder().build();
50+
public static final GenericInterner<Right> RIGHT_INTERNER = new GenericInterner<>();
4951

5052
/**
5153
* Устанавливать права для новых объектов
@@ -97,8 +99,8 @@ public static class ObjectRight {
9799
}
98100

99101
@Value
100-
@ToString(of = {"name"})
101-
@EqualsAndHashCode(of = {"name"})
102+
@ToString(of = {"name", "value"})
103+
@EqualsAndHashCode(of = {"name", "value"})
102104
@Builder
103105
public static class Right {
104106
/**

src/main/java/com/github/_1c_syntax/bsl/mdo/support/MultiLanguageString.java

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo.support;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.support;
2323

24-
import lombok.AllArgsConstructor;
24+
import com.github._1c_syntax.utils.StringInterner;
2525
import lombok.NonNull;
2626
import lombok.Value;
2727

@@ -34,22 +34,30 @@
3434
* Используется для хранения текстовой строки на разных языках
3535
*/
3636
@Value
37-
@AllArgsConstructor
3837
public class MultiLanguageString {
3938

4039
/**
4140
* Ссылка на пустой элемент
4241
*/
4342
public static final MultiLanguageString EMPTY = new MultiLanguageString(Collections.emptyMap());
4443

44+
private static final StringInterner stringInterner = new StringInterner();
45+
4546
/**
4647
* Содержимое описания для каждого языка
4748
*/
4849
Map<String, String> content;
4950

51+
public MultiLanguageString(Map<String, String> source) {
52+
Map<String, String> newContent = new HashMap<>();
53+
source.forEach(
54+
(langKey, text) -> newContent.put(stringInterner.intern(langKey), text));
55+
content = newContent;
56+
}
57+
5058
public MultiLanguageString(@NonNull MultiLanguageString first, @NonNull MultiLanguageString second) {
5159
var fullContent = new HashMap<>(first.getContent());
52-
fullContent.putAll(second.getContent());
60+
putContent(fullContent, second);
5361
content = fullContent;
5462
}
5563

@@ -68,7 +76,7 @@ public static MultiLanguageString of(@NonNull List<MultiLanguageString> strings)
6876
return strings.get(0);
6977
} else {
7078
Map<String, String> content = new HashMap<>();
71-
strings.forEach(string -> content.putAll(string.getContent()));
79+
strings.forEach(string -> putContent(content, string));
7280
return new MultiLanguageString(content);
7381
}
7482
}
@@ -103,4 +111,9 @@ public static MultiLanguageString of(@NonNull List<MultiLanguageString> strings)
103111
public boolean isEmpty() {
104112
return this == EMPTY;
105113
}
114+
115+
private static void putContent(Map<String, String> destination, MultiLanguageString source) {
116+
source.getContent().forEach(
117+
(langKey, text) -> destination.put(stringInterner.intern(langKey), text));
118+
}
106119
}

src/main/java/com/github/_1c_syntax/bsl/mdo/support/RoleRight.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo.support;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.support;
2323

2424
import lombok.AllArgsConstructor;
2525
import lombok.Getter;
@@ -96,7 +96,11 @@ public enum RoleRight implements EnumWithValue {
9696
INTERACTIVE_EXECUTE("InteractiveExecute"),
9797
TECHNICAL_SPECIALIST_MODE("TechnicalSpecialistMode"),
9898
INTERACTIVE_START("InteractiveStart"),
99-
START("Start");
99+
START("Start"),
100+
STANDARD_AUTHENTICATION_CHANGE("StandardAuthenticationChange"),
101+
SESSION_STANDARD_AUTHENTICATION_CHANGE("SessionStandardAuthenticationChange"),
102+
SESSION_OS_AUTHENTICATION_CHANGE("SessionOSAuthenticationChange")
103+
;
100104

101105
@Accessors(fluent = true)
102106
private final String value;

src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.reader;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.reader;
2323

2424
import com.github._1c_syntax.bsl.mdclasses.MDClass;
2525
import com.github._1c_syntax.bsl.mdclasses.MDClasses;

src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.reader;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.reader;
2323

2424
import com.github._1c_syntax.bsl.mdclasses.MDClass;
2525
import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream;
@@ -65,5 +65,4 @@ default Converter getReflectionConverter() {
6565
MDClass readConfiguration();
6666

6767
MDClass readExternalSource();
68-
6968
}

src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/EnumConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static <T extends Enum<T> & EnumWithValue> T fromValue(Class<T> clazz, S
4949
return item;
5050
}
5151
}
52-
throw new IllegalArgumentException(value);
52+
throw new IllegalArgumentException(clazz.getName() + " " + value);
5353
}
5454

5555
@Override

src/main/java/com/github/_1c_syntax/bsl/reader/common/converter/RoleDataConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.github._1c_syntax.bsl.mdo.storage.RoleData;
2525
import com.github._1c_syntax.bsl.reader.common.TransformationUtils;
2626
import com.github._1c_syntax.bsl.reader.common.xstream.ReadConverter;
27+
import com.github._1c_syntax.utils.GenericInterner;
2728
import com.thoughtworks.xstream.converters.UnmarshallingContext;
2829
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
2930

@@ -89,7 +90,8 @@ private static RoleData.Right readRight(HierarchicalStreamReader reader, Unmarsh
8990
TransformationUtils.setValue(builder, name, value);
9091
reader.moveUp();
9192
}
92-
return builder.build();
93+
94+
return RoleData.RIGHT_INTERNER.intern(builder.build());
9395
}
9496

9597
@Override

0 commit comments

Comments
 (0)