File tree 2 files changed +6
-12
lines changed
2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,13 @@ func EscapingObjects(n ast.Node, info *types.Info) []*types.Var {
14
14
bottomScopes : make (map [* types.Scope ]bool ),
15
15
}
16
16
ast .Walk (& v , n )
17
- var list []* types.Var
18
- for obj := range v .escaping {
19
- list = append (list , obj )
20
- }
21
- return list
17
+ return v .ordered
22
18
}
23
19
24
20
type escapeAnalysis struct {
25
21
info * types.Info
26
22
escaping map [* types.Var ]bool
23
+ ordered []* types.Var
27
24
topScope * types.Scope
28
25
bottomScopes map [* types.Scope ]bool
29
26
}
@@ -57,7 +54,10 @@ func (v *escapingObjectCollector) Visit(node ast.Node) (w ast.Visitor) {
57
54
if obj , ok := v .analysis .info .Uses [id ].(* types.Var ); ok {
58
55
for s := obj .Parent (); s != nil ; s = s .Parent () {
59
56
if s == v .analysis .topScope {
60
- v .analysis .escaping [obj ] = true
57
+ if ! v .analysis .escaping [obj ] {
58
+ v .analysis .escaping [obj ] = true
59
+ v .analysis .ordered = append (v .analysis .ordered , obj )
60
+ }
61
61
break
62
62
}
63
63
if v .analysis .bottomScopes [s ] {
Original file line number Diff line number Diff line change @@ -397,12 +397,6 @@ func (fc *funcContext) handleEscapingVars(n ast.Node) {
397
397
398
398
var names []string
399
399
objs := analysis .EscapingObjects (n , fc .pkgCtx .Info .Info )
400
- sort .Slice (objs , func (i , j int ) bool {
401
- if objs [i ].Name () == objs [j ].Name () {
402
- return objs [i ].Pos () < objs [j ].Pos ()
403
- }
404
- return objs [i ].Name () < objs [j ].Name ()
405
- })
406
400
for _ , obj := range objs {
407
401
names = append (names , fc .objectName (obj ))
408
402
fc .pkgCtx .escapingVars [obj ] = true
You can’t perform that action at this time.
0 commit comments