Skip to content

Commit

Permalink
feat: use bytebufferpool
Browse files Browse the repository at this point in the history
  • Loading branch information
Equationzhao committed May 31, 2024
1 parent 479e654 commit bcd729a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/content/extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package content
import (
"encoding/xml"
"fmt"
"github.com/valyala/bytebufferpool"

"github.com/Equationzhao/g/internal/global"
"github.com/Equationzhao/g/internal/item"
Expand All @@ -16,15 +17,17 @@ type ExtendedEnabler struct{}
const Extended = global.NameOfExtended

func formatBytes(bytes []byte) string {
result := "["
res := bytebufferpool.Get()
defer bytebufferpool.Put(res)
_ = res.WriteByte('[')
for i, b := range bytes {
if i > 0 {
result += ", "
_, _ = res.WriteString(", ")
}
result += fmt.Sprintf("%02x", b)
_, _ = res.WriteString(fmt.Sprintf("%02x", b))
}
result += "]"
return result
_ = res.WriteByte(']')
return res.String()
}

// formatXattrValue attempts to parse the xattr value and returns a human-readable string.
Expand Down

0 comments on commit bcd729a

Please sign in to comment.