From c702faf65dee037480821f58a8375831139ccf27 Mon Sep 17 00:00:00 2001 From: himeshr Date: Fri, 8 Nov 2024 19:19:52 +0530 Subject: [PATCH] avniproject/avni-client#1544 | Optimize search for parentFormElement using hashMap --- src/application/FormElementGroup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/application/FormElementGroup.js b/src/application/FormElementGroup.js index 65c5fd4..f02b276 100644 --- a/src/application/FormElementGroup.js +++ b/src/application/FormElementGroup.js @@ -236,10 +236,11 @@ class FormElementGroup extends BaseEntity { } nonVoidedFormElements() { + const mapOfFormElementsByUUID = _.keyBy(this.formElements, 'uuid'); return _.filter(this.formElements, (formElement) => { let parentFormElement; if (!_.isNil(formElement.groupUuid)) - parentFormElement = _.find(this.formElements, (fe) => fe.uuid === formElement.groupUuid); + parentFormElement = mapOfFormElementsByUUID[formElement.groupUuid]; return !formElement.voided && (_.isNil(parentFormElement) || !parentFormElement.voided); }); }