From 0679d1dd4b957c65e3f72679712cae74dec5abd0 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Thu, 9 Apr 2020 20:57:44 +0200 Subject: [PATCH] autopilot: append instead of appends in a loop --- autopilot/agent.go | 5 ++--- autopilot/choice_test.go | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/autopilot/agent.go b/autopilot/agent.go index 6fe72f98..90c2bbdc 100644 --- a/autopilot/agent.go +++ b/autopilot/agent.go @@ -386,9 +386,8 @@ func mergeChanState(pendingChans map[NodeID]Channel, numChans := len(pendingChans) + len(activeChans) totalChans := make([]Channel, 0, numChans) - for _, activeChan := range activeChans.Channels() { - totalChans = append(totalChans, activeChan) - } + totalChans = append(totalChans, activeChans.Channels()...) + for _, pendingChan := range pendingChans { totalChans = append(totalChans, pendingChan) } diff --git a/autopilot/choice_test.go b/autopilot/choice_test.go index 850b4440..bde48b0d 100644 --- a/autopilot/choice_test.go +++ b/autopilot/choice_test.go @@ -139,10 +139,7 @@ func assertChoice(w []float64, iterations int) bool { } // The sum of choices must be exactly iterations of course. - if totalChoices != iterations { - return false - } - return true + return totalChoices == iterations }