Skip to content

Commit d350d1f

Browse files
committed
improved Go code
1 parent 2335d09 commit d350d1f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

words_extractor_go/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Pair struct {
2222

2323
func main() {
2424
with_channels()
25-
without_channels()
25+
without_channels() // 3x faster
2626
}
2727

2828
func without_channels() {
@@ -40,9 +40,8 @@ func without_channels() {
4040
paths, _ := doublestar.Glob("../data/**/*.yml")
4141

4242
items_count := len(paths)
43-
43+
wg.Add(items_count)
4444
for _, path := range paths {
45-
wg.Add(1)
4645
go processFile(&wg, outdir, path, false)
4746
}
4847
wg.Wait()
@@ -52,7 +51,7 @@ func without_channels() {
5251
}
5352

5453
func with_channels() {
55-
queue := make(chan string)
54+
queue := make(chan string, 8)
5655

5756
t := time.Now()
5857
defer timeTrack(t)

0 commit comments

Comments
 (0)