From f5ab6a3f5ecbb7129f2fea8ccaecc8dbbadbc261 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Mon, 19 Nov 2018 10:46:09 -0800 Subject: [PATCH] refactor(commands): cleanup makeDagNodeLinkResults License: MIT Signed-off-by: hannahhoward --- core/commands/ls.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/core/commands/ls.go b/core/commands/ls.go index cf4d7b9666b..422f554d1a7 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -212,20 +212,15 @@ The JSON output contains type information. } func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult { - linkResults := make(chan unixfs.LinkResult) - go func() { - defer close(linkResults) - for _, l := range dagnode.Links() { - select { - case linkResults <- unixfs.LinkResult{ - Link: l, - Err: nil, - }: - case <-req.Context.Done(): - return - } + links := dagnode.Links() + linkResults := make(chan unixfs.LinkResult, len(links)) + defer close(linkResults) + for _, l := range links { + linkResults <- unixfs.LinkResult{ + Link: l, + Err: nil, } - }() + } return linkResults }