例えば、append していくけど、必ず100個以内で収まると分かってるならスライスを
s := make([]string, 0, 100)
と作っておくと
s = append(s, "foo")
を何回やってもメモリの伸長が行われないんです。(最初から作っちゃってるので)
Thread
Login to reply
Replies ()
No replies yet. Be the first to leave a comment!
No replies yet. Be the first to leave a comment!