From fb519fa547cec14c0300846dc928bf72d8441046 Mon Sep 17 00:00:00 2001 From: NoTryNoSuccess <46515610+notrynosuccess@users.noreply.github.com> Date: Fri, 27 May 2022 17:19:40 +0800 Subject: [PATCH] core/mr:a little optimization for collector initialization in ForEach function (#1937) Co-authored-by: notrynosuccess --- core/mr/mapreduce.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mr/mapreduce.go b/core/mr/mapreduce.go index e7763f0e..23d70bd0 100644 --- a/core/mr/mapreduce.go +++ b/core/mr/mapreduce.go @@ -102,12 +102,12 @@ func ForEach(generate GenerateFunc, mapper ForEachFunc, opts ...Option) { options := buildOptions(opts...) panicChan := &onceChan{channel: make(chan interface{})} source := buildSource(generate, panicChan) - collector := make(chan interface{}, options.workers) + collector := make(chan interface{}) done := make(chan lang.PlaceholderType) go executeMappers(mapperContext{ ctx: options.ctx, - mapper: func(item interface{}, writer Writer) { + mapper: func(item interface{}, _ Writer) { mapper(item) }, source: source,