Merge pull request #14 from libp2p/nit/simple-reflect

nit: avoid ValueOf
This commit is contained in:
Łukasz Magiera 2019-06-27 19:40:02 +02:00 committed by GitHub
commit 0c299185af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,9 +230,9 @@ func newNode(typ reflect.Type) *node {
}
func (n *node) emit(event interface{}) {
eval := reflect.ValueOf(event)
if eval.Type() != n.typ {
panic(fmt.Sprintf("Emit called with wrong type. expected: %s, got: %s", n.typ, eval.Type()))
typ := reflect.TypeOf(event)
if typ != n.typ {
panic(fmt.Sprintf("Emit called with wrong type. expected: %s, got: %s", n.typ, typ))
}
n.lk.RLock()