From 73ed07bd8552aa72629c62cd0e12f802a4bf06f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Senart?= Date: Wed, 2 Jul 2014 18:00:47 +0200 Subject: [PATCH] Use chan struct{} for semaphores With semaphores we don't actually care about the value passed in. It makes sense to use a 0 bytes type in these cases. There is also the added benefit of compiler optimisations for this specific use case as described here: https://docs.google.com/document/d/1yIAYmbvL3JxOKOjuCyon7JhW4cSv1wy5hC0ApeGMV9s/pub --- scriptval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scriptval.go b/scriptval.go index 1e300ebad..f931c88f6 100644 --- a/scriptval.go +++ b/scriptval.go @@ -25,7 +25,7 @@ type txValidateItem struct { // function that is intended to be in run multiple goroutines. type txValidator struct { validateChan chan *txValidateItem - quitChan chan bool + quitChan chan struct{} resultChan chan error txStore TxStore flags btcscript.ScriptFlags @@ -181,7 +181,7 @@ func (v *txValidator) Validate(items []*txValidateItem) error { func newTxValidator(txStore TxStore, flags btcscript.ScriptFlags) *txValidator { return &txValidator{ validateChan: make(chan *txValidateItem), - quitChan: make(chan bool), + quitChan: make(chan struct{}), resultChan: make(chan error), txStore: txStore, flags: flags,