From 6df775955fd2fcd023ad7ccb91a937f0a0381400 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 27 Jan 2024 21:17:04 +0600 Subject: [PATCH] Minor optimization. Raised "progress=end" after data:= Scanner Out.Text(). --- src/handler/convertor.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/handler/convertor.go b/src/handler/convertor.go index 919b2f4..e09accb 100644 --- a/src/handler/convertor.go +++ b/src/handler/convertor.go @@ -164,6 +164,14 @@ func (p progress) Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error { scannerOut := bufio.NewScanner(stdOut) for scannerOut.Scan() { data := scannerOut.Text() + + if strings.Contains(data, "progress=end") { + p.progressbar.Value = p.totalDuration + p.progressbar.Refresh() + isProcessCompleted = true + break + } + re := regexp.MustCompile(`frame=(\d+)`) a := re.FindAllStringSubmatch(data, -1) @@ -174,12 +182,6 @@ func (p progress) Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error { } progress = float64(c) } - if strings.Contains(data, "progress=end") { - p.progressbar.Value = p.totalDuration - p.progressbar.Refresh() - isProcessCompleted = true - break - } if p.progressbar.Value != progress { p.progressbar.Value = progress p.progressbar.Refresh()