File tree 1 file changed +6
-14
lines changed
1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -20,32 +20,24 @@ func Fetch(options map[string]bool) []Node {
20
20
files , err := ioutil .ReadDir ("." )
21
21
if err != nil { log .Fatal (err ) }
22
22
23
- count := 0
24
- for i := 0 ; i < len (files ); i ++ {
25
- if ! options ["all" ] && []rune (files [i ].Name ())[0 ] == '.' { continue }
26
- count ++
27
- }
28
-
29
- if options ["all" ] { count += 2 }
30
-
31
- nodes := make ([]Node , count )
23
+ nodes := make ([]Node , len (files )+ 2 )
32
24
33
- count = 0
25
+ index : = 0
34
26
if options ["all" ] {
35
27
file , _ := os .Stat ("." )
36
28
nodes [0 ] = new (file )
37
29
file , _ = os .Stat (".." )
38
30
nodes [1 ] = new (file )
39
- count += 2
31
+ index += 2
40
32
}
41
33
42
34
for i := 0 ; i < len (files ); i ++ {
43
35
if ! options ["all" ] && []rune (files [i ].Name ())[0 ] == '.' { continue }
44
- nodes [count ] = new (files [i ])
45
- count ++
36
+ nodes [index ] = new (files [i ])
37
+ index ++
46
38
}
47
39
48
- return nodes
40
+ return nodes [: index ]
49
41
}
50
42
51
43
func new (file os.FileInfo ) Node {
You can’t perform that action at this time.
0 commit comments