diff --git a/lang/core/iter/filter.go b/lang/core/iter/filter.go index a92589a7..5123e06f 100644 --- a/lang/core/iter/filter.go +++ b/lang/core/iter/filter.go @@ -449,7 +449,9 @@ func (obj *FilterFunc) Call(ctx context.Context, args []types.Value) (types.Valu // Every time the FuncValue or the length of the list changes, recreate // the subgraph, by calling the FuncValue N times on N nodes, each of - // which extracts one of the N values in the list. + // which extracts one of the N values in the list. If the contents of + // the list change (BUT NOT THE LENGTH) then it's okay to use the + // existing graph, because the shape is the same! n := len(newInputList.List()) @@ -459,10 +461,6 @@ func (obj *FilterFunc) Call(ctx context.Context, args []types.Value) (types.Valu } obj.lastInputListLength = n - if b && !c { // different length list - return types.NewNil(), nil // dummy value - } - // If we have a new function or the length of the input list has // changed, then we need to replace the subgraph with a new one that // uses the new function the correct number of times. diff --git a/lang/core/iter/map.go b/lang/core/iter/map.go index e1fc6b78..40fa5050 100644 --- a/lang/core/iter/map.go +++ b/lang/core/iter/map.go @@ -393,7 +393,9 @@ func (obj *MapFunc) Call(ctx context.Context, args []types.Value) (types.Value, // Every time the FuncValue or the length of the list changes, recreate // the subgraph, by calling the FuncValue N times on N nodes, each of - // which extracts one of the N values in the list. + // which extracts one of the N values in the list. If the contents of + // the list change (BUT NOT THE LENGTH) then it's okay to use the + // existing graph, because the shape is the same! n := len(newInputList.List()) @@ -403,10 +405,6 @@ func (obj *MapFunc) Call(ctx context.Context, args []types.Value) (types.Value, } obj.lastInputListLength = n - if b && !c { // different length list - return types.NewNil(), nil // dummy value - } - // If we have a new function or the length of the input list has // changed, then we need to replace the subgraph with a new one that // uses the new function the correct number of times.