We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
参考源码,Join本身就是调用了套了一个Builder来存新字符串,所以这两个效率应该是一样的? go1.15.2 darwin/amd6
Join
Builder
func Join(elems []string, sep string) string { switch len(elems) { case 0: return "" case 1: return elems[0] } n := len(sep) * (len(elems) - 1) for i := 0; i < len(elems); i++ { n += len(elems[i]) } var b Builder b.Grow(n) b.WriteString(elems[0]) for _, s := range elems[1:] { b.WriteString(sep) b.WriteString(s) } return b.String() }
另外似乎strings.Builder是个改写版的迷你bytes.Buffer?
strings.Builder
bytes.Buffer
The text was updated successfully, but these errors were encountered:
No branches or pull requests
参考源码,
Join
本身就是调用了套了一个Builder
来存新字符串,所以这两个效率应该是一样的?go1.15.2 darwin/amd6
另外似乎strings.Builder
是个改写版的迷你bytes.Buffer
?The text was updated successfully, but these errors were encountered: