Check-in [bca8ee3e12]
Overview
SHA1:bca8ee3e121081e2aeadbd1710a960a4cd41a214
Date: 2015-01-26 23:02:10
User: spaskalev
Comment:full dep traversal in the collecting handler
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2015-03-19
20:17
[061baeefcb] A simple parser combinator library (user: spaskalev, tags: trunk)
2015-01-26
23:02
[bca8ee3e12] full dep traversal in the collecting handler (user: spaskalev, tags: trunk)
21:32
[3861ae4c57] Added missing depends interation in the collecting handler (user: spaskalev, tags: trunk)
Changes

Modified src/0dev.org/commands/tbd/tbd.go from [00e85b5d82] to [2547f40cdb].

   216    216   		}
   217    217   		return action{stop: true}
   218    218   	}
   219    219   }
   220    220   
   221    221   // Returns a handler that stores every seen task and an ancillary function to retrieve those
   222    222   func collecting() (handler, func() tasks) {
   223         -	var seen = make(map[*task]struct{})
          223  +	var seen = make(map[*task]bool)
   224    224   	return func(t *task) action {
   225         -			seen[t] = struct{}{}
   226         -			for _, dep := range t.depends {
   227         -				seen[dep] = struct{}{}
          225  +			depth := tasks{t}
          226  +			for i := 0; i < len(depth); i++ {
          227  +				if !seen[depth[i]] {
          228  +					seen[depth[i]] = true
          229  +					depth = append(depth, depth[i].depends...)
          230  +				}
   228    231   			}
   229    232   			return action{}
   230    233   		}, func() tasks {
   231    234   			seq := make(tasks, 0, len(seen))
   232    235   			for k, _ := range seen {
   233    236   				seq = append(seq, k)
   234    237   			}
   235    238   			sort.Stable(seq)
   236    239   			return seq
   237    240   		}
   238    241   }