[json] IJPL-157032 Prefer storing resolved tree nodes in a set to avoid processing the effective same branches multiple times

GitOrigin-RevId: bc3af9a831c28cf6b9d9c7f46a1756987e90ef0a
This commit is contained in:
Nikita Katkov
2024-06-21 02:09:23 +02:00
committed by intellij-monorepo-bot
parent 14c0629620
commit b1d33aaa24

View File

@@ -2,6 +2,7 @@
package com.jetbrains.jsonSchema.impl;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
@@ -12,13 +13,13 @@ public final class MatchResult {
public final List<JsonSchemaObject> mySchemas;
public final List<Collection<? extends JsonSchemaObject>> myExcludingSchemas;
private MatchResult(final @NotNull List<JsonSchemaObject> schemas, final @NotNull List<Collection<? extends JsonSchemaObject>> excludingSchemas) {
mySchemas = Collections.unmodifiableList(schemas);
private MatchResult(final @NotNull Collection<JsonSchemaObject> schemas, final @NotNull List<Collection<? extends JsonSchemaObject>> excludingSchemas) {
mySchemas = Collections.unmodifiableList(new SmartList<>(schemas));
myExcludingSchemas = Collections.unmodifiableList(excludingSchemas);
}
public static MatchResult create(@NotNull JsonSchemaTreeNode root) {
List<JsonSchemaObject> schemas = new ArrayList<>();
Collection<JsonSchemaObject> schemas = new LinkedHashSet<>();
Int2ObjectMap<List<JsonSchemaObject>> oneOfGroups = new Int2ObjectOpenHashMap<>();
iterateTree(root, node -> {
if (node.isAny()) return true;