mirror of https://github.com/docker/cli.git
Merge pull request #1432 from thaJeztah/18.09_backport_use_string_builder
[18.09] backport using strings.Builder instead of string appending
This commit is contained in:
commit
22336b332c
|
@ -3,6 +3,7 @@ package image
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -73,14 +74,20 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(report.ImagesDeleted) > 0 {
|
if len(report.ImagesDeleted) > 0 {
|
||||||
output = "Deleted Images:\n"
|
var sb strings.Builder
|
||||||
|
sb.WriteString("Deleted Images:\n")
|
||||||
for _, st := range report.ImagesDeleted {
|
for _, st := range report.ImagesDeleted {
|
||||||
if st.Untagged != "" {
|
if st.Untagged != "" {
|
||||||
output += fmt.Sprintln("untagged:", st.Untagged)
|
sb.WriteString("untagged: ")
|
||||||
|
sb.WriteString(st.Untagged)
|
||||||
|
sb.WriteByte('\n')
|
||||||
} else {
|
} else {
|
||||||
output += fmt.Sprintln("deleted:", st.Deleted)
|
sb.WriteString("deleted: ")
|
||||||
|
sb.WriteString(st.Deleted)
|
||||||
|
sb.WriteByte('\n')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
output = sb.String()
|
||||||
spaceReclaimed = report.SpaceReclaimed
|
spaceReclaimed = report.SpaceReclaimed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue