Skip to content

Commit

Permalink
perf(movie): Add default buffer size to decrease the memory cost of l…
Browse files Browse the repository at this point in the history
…oading a movie
  • Loading branch information
gabe565 committed Sep 3, 2024
1 parent 6588c85 commit c2f82f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/movie/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ import (
)

func (m *Movie) LoadFile(path string, src io.Reader, speed float64) error {
const defaultWidth, defaultHeight = 67, 13

m.Filename = filepath.Base(path)

m.Frames = make([]Frame, 0, 2000)
var f Frame
var buf bytes.Buffer
buf.Grow(defaultWidth * defaultHeight)
scanner := bufio.NewScanner(src)

// Build part of every frame, excluding progress bar and bottom padding
Expand Down

0 comments on commit c2f82f2

Please sign in to comment.