Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: reduce "growslice" in "dumpRowValuesBinary" #4916

Merged
merged 9 commits into from Nov 2, 2017
3 changes: 2 additions & 1 deletion server/util.go
Expand Up @@ -250,7 +250,6 @@ func dumpRowValuesBinary(alloc arena.Allocator, columns []*ColumnInfo, row []typ
err = mysql.ErrMalformPacket
return
}
data = append(data, mysql.OKHeader)
nullsLen := ((len(columns) + 7 + 2) / 8)
nulls := make([]byte, nullsLen)
for i, val := range row {
Expand All @@ -260,6 +259,8 @@ func dumpRowValuesBinary(alloc arena.Allocator, columns []*ColumnInfo, row []typ
nulls[bytePos] |= 1 << bitPos
}
}
data = make([]byte, 0, 1+nullsLen+8*len(row))
data = append(data, mysql.OKHeader)
data = append(data, nulls...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about alloc data and nulls in one slice to avoid this operation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

for i, val := range row {
switch val.Kind() {
Expand Down