From 9be79a03301f1974d125a784205f3272abadd9ae Mon Sep 17 00:00:00 2001 From: kwahlin Date: Wed, 20 Nov 2024 14:08:11 +0100 Subject: [PATCH] Always cache results from JsonLd.getSubClasses --- whelk-core/src/main/groovy/whelk/JsonLd.groovy | 2 ++ whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/whelk-core/src/main/groovy/whelk/JsonLd.groovy b/whelk-core/src/main/groovy/whelk/JsonLd.groovy index 1b10b2463f..c6bb098607 100644 --- a/whelk-core/src/main/groovy/whelk/JsonLd.groovy +++ b/whelk-core/src/main/groovy/whelk/JsonLd.groovy @@ -2,6 +2,7 @@ package whelk import groovy.transform.CompileStatic import groovy.transform.Immutable +import groovy.transform.Memoized import groovy.transform.TypeChecked import groovy.transform.TypeCheckingMode import org.apache.logging.log4j.LogManager @@ -701,6 +702,7 @@ class JsonLd { return asList(entity['@type']).any { isSubClassOf((String) it, baseType) } } + @Memoized Set getSubClasses(String type) { return getSubTerms(type, superClassOf, subClassesByType) } diff --git a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy index 5774662aa7..0e828ba6a9 100644 --- a/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy +++ b/whelktool/src/main/groovy/whelk/datatool/form/MatchForm.groovy @@ -308,7 +308,6 @@ class MatchForm { return mappings } - @Memoized private static Set getSubtypes(String type, JsonLd jsonLd) { return jsonLd.getSubClasses(type) }