From bcb9d262c967f1e98ce07561cb02072f113a9c01 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 | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/core/commands/ls.go b/core/commands/ls.go index cf4d7b9666b7..b023134da133 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -212,20 +212,14 @@ 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)) + for _, l := range links { + linkResults <- unixfs.LinkResult{ + Link: l, + Err: nil, } - }() + } return linkResults }