MCPcopy
hub / github.com/Terry-Mao/goim / JoinInt64s

Function JoinInt64s

pkg/strings/ints.go:58–77  ·  view source on GitHub ↗

JoinInt64s format int64 slice like:n1,n2,n3.

(is []int64, p string)

Source from the content-addressed store, hash-verified

56
57// JoinInt64s format int64 slice like:n1,n2,n3.
58func JoinInt64s(is []int64, p string) string {
59 if len(is) == 0 {
60 return ""
61 }
62 if len(is) == 1 {
63 return strconv.FormatInt(is[0], 10)
64 }
65 buf := bfPool.Get().(*bytes.Buffer)
66 for _, i := range is {
67 buf.WriteString(strconv.FormatInt(i, 10))
68 buf.WriteString(p)
69 }
70 if buf.Len() > 0 {
71 buf.Truncate(buf.Len() - 1)
72 }
73 s := buf.String()
74 buf.Reset()
75 bfPool.Put(buf)
76 return s
77}
78
79// SplitInt64s split string into int64 slice.
80func SplitInt64s(s, p string) ([]int64, error) {

Callers 1

TestInt64Function · 0.85

Calls 6

WriteStringMethod · 0.80
LenMethod · 0.80
GetMethod · 0.45
StringMethod · 0.45
ResetMethod · 0.45
PutMethod · 0.45

Tested by 1

TestInt64Function · 0.68