From 76a3273ba83d46169ad94639799c1178edd608cd Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Thu, 5 Dec 2024 11:56:52 +0530 Subject: [PATCH] fix: Moving from List datastructure to Set to reduce the number of array list creations. --- .../onload/internal/OnLoadExecutablesUtilCEImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java index ef535c21694f..5d79bc7f1a5d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java @@ -525,7 +525,7 @@ private Mono> getPossibleEntityReferences( // We want to be finding both type of references final int entityTypes = EXECUTABLE_ENTITY_REFERENCES | WIDGET_ENTITY_REFERENCES; return executableNameToExecutableMono - .zipWith(getPossibleEntityParentsMap(new ArrayList<>(bindings), entityTypes, evalVersion)) + .zipWith(getPossibleEntityParentsMap(bindings, entityTypes, evalVersion)) .map(tuple -> { Map executableMap = tuple.getT1(); // For each binding, here we receive a set of possible references to global entities @@ -585,7 +585,7 @@ private Mono> getPossibleEntityReferences( private Mono>> getPossibleEntityReferencesMap( Mono> executableNameToExecutableMono, - List bindings, + Set bindings, int evalVersion, Set bindingsInDsl) { // We want to be finding both type of references @@ -666,9 +666,9 @@ private Mono>> getPossibleEntityReferences * @return A mono of a map of each of the provided binding values to the possible set of EntityDependencyNodes found in the binding */ private Mono>> getPossibleEntityParentsMap( - List bindings, int types, int evalVersion) { + Set bindings, int types, int evalVersion) { Flux>> findingToReferencesFlux = - astService.getPossibleReferencesFromDynamicBinding(bindings, evalVersion); + astService.getPossibleReferencesFromDynamicBinding(new ArrayList<>(bindings), evalVersion); return MustacheHelper.getPossibleEntityParentsMap(findingToReferencesFlux, types); } @@ -701,7 +701,7 @@ private Mono> addDirectlyReferencedExecutablesToGr int evalVersion) { Map> bindingToWidgetNodesMap = new HashMap<>(); - List allBindings = new ArrayList<>(); + Set allBindings = new HashSet<>(); widgetDynamicBindingsMap.forEach((widgetName, bindingsInWidget) -> { EntityDependencyNode widgetDependencyNode = @@ -1220,7 +1220,7 @@ private Mono> addWidgetRelationshipToGraph( // This part will ensure that we are discovering widget to widget relationships. return Flux.fromIterable(widgetBindingMap.entrySet()) .flatMap(widgetBindingEntries -> getPossibleEntityParentsMap( - new ArrayList<>(widgetBindingEntries.getValue()), entityTypes, evalVersion) + widgetBindingEntries.getValue(), entityTypes, evalVersion) .map(possibleParentsMap -> { possibleParentsMap.entrySet().stream().forEach(entry -> { if (entry.getValue() == null || entry.getValue().isEmpty()) {