sort-cli: magic constants

This commit is contained in:
2024-01-29 21:21:37 +03:00
parent 380099b9b3
commit e755e846c1
3 changed files with 9 additions and 4 deletions

View File

@ -9,6 +9,9 @@ import (
"strings"
)
// NL New line constant
const NL = "\n"
type content [][]byte
func (c *content) Sort(reverse bool) {
@ -42,14 +45,14 @@ func (c *content) String() string {
for _, line := range lines {
n += len(line)
}
n += len(lines) * len("\n")
n += len(lines) * len(NL)
var sb strings.Builder
sb.Grow(n)
for i, line := range lines {
if i > 0 {
sb.WriteString("\n")
sb.WriteString(NL)
}
for _, rn := range line {