adrg / sysfont

Golang identification and matching of system fonts
https://pkg.go.dev/github.com/adrg/sysfont
MIT License
43 stars 13 forks source link

Use optimized filepath.WalkDir function instead of filepath.Walk #15

Open hismailbulut opened 2 years ago

hismailbulut commented 2 years ago

A simple test shows the performance difference

Test with filepath.Walk: goos: windows goarch: amd64 pkg: github.com/adrg/sysfont cpu: Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz BenchmarkNewFinder-4 3 466802100 ns/op PASS ok github.com/adrg/sysfont 2.978s

Test with filepath.WalkDir: goos: windows goarch: amd64 pkg: github.com/adrg/sysfont cpu: Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz BenchmarkNewFinder-4 3 427294700 ns/op PASS ok github.com/adrg/sysfont 2.743s

adrg commented 2 years ago

Hi @hismailbulut. Thank you for the PR. I would love to adopt this change at this point. However filepath.WalkDir was introduced in Go v1.16 (which was just released on February 16, 2021).

That means that I would force the Go v1.16 restriction on all packages already using this one in future releases. I'll most certainly transition to filepath.WalkDir in the future, but I think it's a bit too soon right now.