Skip to content

Commit

Permalink
remove unnecessary bytes.Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbraemer committed Jun 19, 2021
1 parent efe2827 commit 0327262
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,17 @@ func (d *Dispatcher) smartUsage(ctx context.Context, node CommandNode, optional
}
return b.String()
} else if len(children) > 1 {
s := new(bytes.Buffer)
s.WriteRune(openChar)
for i, child := range children {
if i != 0 {
s.WriteRune(UsageOr)
if i == 0 {
b.WriteRune(ArgumentSeparator)
b.WriteRune(openChar)
} else {
b.WriteRune(UsageOr)
}
b.WriteString(child.UsageText())
if i == len(children)-1 {
b.WriteRune(closeChar)
}
s.WriteString(child.UsageText())
}
if len(children) != 0 {
b.WriteRune(ArgumentSeparator)
_, _ = s.WriteTo(b)
b.WriteRune(closeChar)
}
}
}
Expand Down

0 comments on commit 0327262

Please sign in to comment.