preallocate
This commit is contained in:
parent
f144267115
commit
0d5fc2520c
1 changed files with 1 additions and 1 deletions
|
@ -379,7 +379,7 @@ func (d dag) topWalk(visit func(Drawer)) {
|
||||||
// Count indegrees - indegree(v) = len(d[v].in) for each vertex v.
|
// Count indegrees - indegree(v) = len(d[v].in) for each vertex v.
|
||||||
// If indegree(v) = 0, enqueue. Total: O(|V|).
|
// If indegree(v) = 0, enqueue. Total: O(|V|).
|
||||||
queue := make([]Drawer, 0, len(d))
|
queue := make([]Drawer, 0, len(d))
|
||||||
indegree := make(map[Drawer]int)
|
indegree := make(map[Drawer]int, len(d))
|
||||||
for v, e := range d {
|
for v, e := range d {
|
||||||
if len(e.in) == 0 {
|
if len(e.in) == 0 {
|
||||||
queue = append(queue, v)
|
queue = append(queue, v)
|
||||||
|
|
Loading…
Reference in a new issue