Avoid potential reallocs by pre-sizing some slices
There's a couple spots where we know exactly how large the destination buffer should be, so pre-size these to avoid any reallocs to a higher capacity. Signed-off-by: Danny Canter <danny@dcantah.dev>
This commit is contained in:
@@ -1098,9 +1098,9 @@ func getSupplementalGroupsFromPath(root string, filter func(user.Group) bool) ([
|
||||
// if there are no additional groups; just return an empty set
|
||||
return []uint32{}, nil
|
||||
}
|
||||
addlGids := []uint32{}
|
||||
for _, grp := range groups {
|
||||
addlGids = append(addlGids, uint32(grp.Gid))
|
||||
addlGids := make([]uint32, len(groups))
|
||||
for i, grp := range groups {
|
||||
addlGids[i] = uint32(grp.Gid)
|
||||
}
|
||||
return addlGids, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user