[go-nuts] Re: How to fast transpose byte matrix [][]byte in Golang assembly

2020-08-05 Thread peterGo
jake, I do the same thing but I like to have the correct length and capacity. func NewMatrix(r, c int) [][]int { a := make([]int, r*c) m := make([][]int, r) lo, hi := 0, c for i := range m { m[i] = a[lo:hi:hi] lo, hi = hi, hi+c } return m } https://play.go

[go-nuts] Re: How to fast transpose byte matrix [][]byte in Golang assembly

2020-08-05 Thread jake...@gmail.com
Not a direct answer, but one simple improvement you could do is to allocate all the rows together, then break them up by slicing. So instead of your: T := make([][]byte, n) for i := 0; i < n; i++ { T[i] = make([]byte, m) } Do something like: T := make([][]byte, n) Q