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