mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
fix: replace string concatenation in loop with string builder (#505)
This commit is contained in:
parent
f0734709f0
commit
9a3f7a19cb
1 changed files with 4 additions and 3 deletions
7
main.go
7
main.go
|
@ -284,15 +284,16 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error {
|
|||
|
||||
// trim lines
|
||||
lines := strings.Split(string(out), "\n")
|
||||
var content string
|
||||
var cb strings.Builder
|
||||
for i, s := range lines {
|
||||
content += strings.TrimSpace(s)
|
||||
cb.WriteString(strings.TrimSpace(s))
|
||||
|
||||
// don't add an artificial newline after the last split
|
||||
if i+1 < len(lines) {
|
||||
content += "\n"
|
||||
cb.WriteString("\n")
|
||||
}
|
||||
}
|
||||
content := cb.String()
|
||||
|
||||
// display
|
||||
if pager || cmd.Flags().Changed("pager") {
|
||||
|
|
Loading…
Reference in a new issue