From 0d69f13e484f88404d0369e60c7e50f4d8d38fce Mon Sep 17 00:00:00 2001 From: "joy.zhou" Date: Thu, 7 Jan 2021 16:22:51 +0800 Subject: [PATCH] Revert "op: low performance code (#102)" This reverts commit c2248bed2bd3042303eb541644db28e82595b0b0. --- broker/lib/topics/memtopics.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/broker/lib/topics/memtopics.go b/broker/lib/topics/memtopics.go index c2ceb8e..23a795a 100644 --- a/broker/lib/topics/memtopics.go +++ b/broker/lib/topics/memtopics.go @@ -256,24 +256,16 @@ func (this *snode) smatch(topic []byte, qos byte, subs *[]interface{}, qoss *[]b return err } - // If the key is "#", then these subscribers are added to the result set - n, ok := this.snodes[MWC] - if ok { - n.matchQos(qos, subs, qoss) - } - - n, ok = this.snodes[SWC] - if ok { - if err := n.smatch(rem, qos, subs, qoss); err != nil { - return err - } - } - level := string(ntl) - n, ok = this.snodes[level] - if ok { - if err := n.smatch(rem, qos, subs, qoss); err != nil { - return err + + for k, n := range this.snodes { + // If the key is "#", then these subscribers are added to the result set + if k == MWC { + n.matchQos(qos, subs, qoss) + } else if k == SWC || k == level { + if err := n.smatch(rem, qos, subs, qoss); err != nil { + return err + } } }