sliceのベストプラクティス3 length を延長し allocate 済みの領域を使おう 例:構造体のsliceに要素を一つ追加する allocate済みの領域が s の中にあるので、有効利用したい 61 s := make([]BigStruct, 0, c) for i:=0; is = append(s, NewBigStruct(i)) } 構造体は、都度allocateされている
参考文献 ■ Bast, Hannah, et al. "Route planning in transportation networks." Algorithm engineering. Springer, Cham, 2016. 19-80. ■ Geisberger, Robert, et al. "Contraction hierarchies: Faster and simpler hierarchical routing in road networks." International Workshop on Experimental and Efficient Algorithms. Springer, Berlin, Heidelberg, 2008. ■ 最短経路探査アルゴリズムの実装 ■ An Introduction to Contraction Hierarchies ■ The Go Blog Go Slices: usage and internals ■ Macro View of Map Internals In Go