matrix.go: preallocate slice for String() method

To avoid slice growth with append operations.
master
Gyu-Ho Lee 2016-06-04 22:12:17 -07:00
parent 2fde63d288
commit 7a64c70cbc
1 changed files with 2 additions and 2 deletions

View File

@ -87,9 +87,9 @@ func (m matrix) Check() error {
//
// Example: [[1, 2], [3, 4]]
func (m matrix) String() string {
var rowOut []string
rowOut := make([]string, 0, len(m))
for _, row := range m {
var colOut []string
colOut := make([]string, 0, len(row))
for _, col := range row {
colOut = append(colOut, strconv.Itoa(int(col)))
}