all: use bufio.Reader to improve reading speed

This commit is contained in:
Hajime Hoshi 2024-07-29 02:28:37 +09:00
parent 563f2e0e0b
commit ef5ac4175d
2 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@
package main package main
import ( import (
"bufio"
"bytes" "bytes"
_ "embed" _ "embed"
"fmt" "fmt"
@ -81,7 +82,7 @@ func main() {
fmt.Println("Play the default video. You can specify a video file as an argument.") fmt.Println("Play the default video. You can specify a video file as an argument.")
} }
player, err := newMPEGPlayer(in) player, err := newMPEGPlayer(bufio.NewReader(in))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -15,6 +15,7 @@
package mtl_test package mtl_test
import ( import (
"bufio"
"fmt" "fmt"
"image" "image"
"image/color" "image/color"
@ -147,7 +148,7 @@ func readPNG(name string) (image.Image, error) {
defer func() { defer func() {
_ = f.Close() _ = f.Close()
}() }()
return png.Decode(f) return png.Decode(bufio.NewReader(f))
} }
// imageEq reports whether images m, n are considered equivalent. Two images are considered // imageEq reports whether images m, n are considered equivalent. Two images are considered