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

Function JoinInt32s

pkg/strings/ints.go:19–38  ·  view source on GitHub ↗

JoinInt32s format int32 slice like:n1,n2,n3.

(is []int32, p string)

Source from the content-addressed store, hash-verified

17
18// JoinInt32s format int32 slice like:n1,n2,n3.
19func JoinInt32s(is []int32, p string) string {
20 if len(is) == 0 {
21 return ""
22 }
23 if len(is) == 1 {
24 return strconv.FormatInt(int64(is[0]), 10)
25 }
26 buf := bfPool.Get().(*bytes.Buffer)
27 for _, i := range is {
28 buf.WriteString(strconv.FormatInt(int64(i), 10))
29 buf.WriteString(p)
30 }
31 if buf.Len() > 0 {
32 buf.Truncate(buf.Len() - 1)
33 }
34 s := buf.String()
35 buf.Reset()
36 bfPool.Put(buf)
37 return s
38}
39
40// SplitInt32s split string into int32 slice.
41func SplitInt32s(s, p string) ([]int32, error) {

Callers 1

TestInt32Function · 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

TestInt32Function · 0.68