Enable the appendAssign lint check (#1865)

* Make copies of buffers

Avoid reusing one of the incoming arrays as a append extension, and
make a copy of the data. It's cleaner in the long run and possibly
easier for the GC to maintain.

* Avoid appendAssign problems in tag code

Reuse the existing slice when appending.

* Fix appendAssign in encoder_scene_preview_chunk

Appending and creating a new slice is somewhat unintuitive since the
underlying slice might be extended to satisfy the new capacity. This
sometimes leads to faulty logic.

Rewrite the code so it reuses `args` for all appending, and builds one
array clearly in the code. It follows the general style of the function
where `args` is being built in small incremental batches and avoids
the introduction of new names.

* Enable the appendAssign check

This makes us pass all gocritic warnings.

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
SmallCoccinelle
2021-10-20 07:34:19 +02:00
committed by GitHub
parent e513b6ffa5
commit 8b7720e3bf
4 changed files with 10 additions and 12 deletions

View File

@@ -85,11 +85,11 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
"-strict", "-2",
}
args3 := append(args, args2...)
args3 = append(args3, argsAudio...)
finalArgs := append(args3, options.OutputPath)
args = append(args, args2...)
args = append(args, argsAudio...)
args = append(args, options.OutputPath)
_, err := e.run(probeResult.Path, finalArgs, nil)
_, err := e.run(probeResult.Path, args, nil)
return err
}