From 1187c0330a71d28740c0dd8a4a5f40fb1a66ee3b Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 9 Sep 2022 17:04:32 +0400 Subject: [PATCH] faster filter --- .../rescript/FunctionRegistry/Library/FR_List.res | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res index 7be0f9f3..c174272b 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res @@ -73,19 +73,18 @@ module Internals = { accessors: ProjectAccessorsT.t, reducer: ProjectReducerFnT.t, ) => { - let mappedList = aValueArray->Belt.Array.reduceReverse(list{}, (acc, elem) => { - let newElem = Reducer_Expression_Lambda.doLambdaCall( + Js.Array2.filter(aValueArray, elem => { + let result = Reducer_Expression_Lambda.doLambdaCall( aLambdaValue, list{elem}, accessors, reducer, ) - switch newElem { - | IEvBool(true) => list{elem, ...acc} - | _ => acc + switch result { + | IEvBool(true) => true + | _ => false } - }) - mappedList->Belt.List.toArray->Wrappers.evArray + })->Wrappers.evArray } }