Skip to content

Commit f9d9b30

Browse files
committed
refactor&optimization for PushAsserter
1 parent d46afd8 commit f9d9b30

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

assert/assert.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,27 +1062,23 @@ func PushAsserter(i Asserter) (retFn function) {
10621062
var (
10631063
prevFound bool
10641064
prevAsserter asserter
1065+
currentGID int
10651066
)
10661067

10671068
// get pkg lvl asserter
10681069
curAsserter := defAsserter[def]
10691070
// .. to check if we are doing unit tests
10701071
if !curAsserter.isUnitTesting() {
10711072
// .. allow GLS specific asserter. NOTE see current()
1072-
curGoRID := goid()
1073-
//asserterMap.Set(curGoRID, defAsserter[i])
1073+
currentGID = goid()
10741074
asserterMap.Tx(func(m map[int]asserter) {
1075-
cur, found := m[curGoRID]
1076-
if found {
1077-
prevAsserter = cur
1078-
prevFound = found
1079-
}
1080-
m[curGoRID] = defAsserter[i]
1075+
prevAsserter, prevFound = m[currentGID]
1076+
m[currentGID] = defAsserter[i]
10811077
})
10821078
}
10831079
if prevFound {
10841080
return func() {
1085-
asserterMap.Set(goid(), prevAsserter)
1081+
asserterMap.Set(currentGID, prevAsserter)
10861082
}
10871083
}
10881084
return PopAsserter

0 commit comments

Comments
 (0)