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