From b1d33aaa243b89d1c9629f6be73d42cc69db31ce Mon Sep 17 00:00:00 2001 From: Nikita Katkov Date: Fri, 21 Jun 2024 02:09:23 +0200 Subject: [PATCH] [json] IJPL-157032 Prefer storing resolved tree nodes in a set to avoid processing the effective same branches multiple times GitOrigin-RevId: bc3af9a831c28cf6b9d9c7f46a1756987e90ef0a --- json/src/com/jetbrains/jsonSchema/impl/MatchResult.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/json/src/com/jetbrains/jsonSchema/impl/MatchResult.java b/json/src/com/jetbrains/jsonSchema/impl/MatchResult.java index 823c111227f1..2df070985528 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/MatchResult.java +++ b/json/src/com/jetbrains/jsonSchema/impl/MatchResult.java @@ -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 mySchemas; public final List> myExcludingSchemas; - private MatchResult(final @NotNull List schemas, final @NotNull List> excludingSchemas) { - mySchemas = Collections.unmodifiableList(schemas); + private MatchResult(final @NotNull Collection schemas, final @NotNull List> excludingSchemas) { + mySchemas = Collections.unmodifiableList(new SmartList<>(schemas)); myExcludingSchemas = Collections.unmodifiableList(excludingSchemas); } public static MatchResult create(@NotNull JsonSchemaTreeNode root) { - List schemas = new ArrayList<>(); + Collection schemas = new LinkedHashSet<>(); Int2ObjectMap> oneOfGroups = new Int2ObjectOpenHashMap<>(); iterateTree(root, node -> { if (node.isAny()) return true;