From 7341fb38a66624ba8c04482453a41ef5185e1f4e Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 18 Mar 2024 18:05:06 +0100 Subject: [PATCH] Reduce memory consumption --- .../java/org/teavm/dependency/TypeSet.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/teavm/dependency/TypeSet.java b/core/src/main/java/org/teavm/dependency/TypeSet.java index fdceba944..52bb86db0 100644 --- a/core/src/main/java/org/teavm/dependency/TypeSet.java +++ b/core/src/main/java/org/teavm/dependency/TypeSet.java @@ -295,16 +295,27 @@ class TypeSet { } List getConsumers() { - if (consumers == null) { - consumers = new ArrayList<>(); - for (var node : domain()) { - if (node.followers != null) { - consumers.add(new ConsumerWithNode(node.followers.toArray(new DependencyConsumer[0]), node)); - } + if (domain == null) { + return List.of(); + } else if (domain instanceof DependencyNode) { + var node = (DependencyNode) domain; + if (node.followers == null) { + return List.of(); + } else { + return List.of(new ConsumerWithNode(node.followers.toArray(new DependencyConsumer[0]), node)); } - consumers.trimToSize(); + } else { + if (consumers == null) { + consumers = new ArrayList<>(); + for (var node : domain()) { + if (node.followers != null) { + consumers.add(new ConsumerWithNode(node.followers.toArray(new DependencyConsumer[0]), node)); + } + } + consumers.trimToSize(); + } + return consumers; } - return consumers; } int typeCount() {