mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cleanup: allocate slice with known size
As the input capabilities size is known, it is better to allocate slice with a specified size. Signed-off-by: Ben Ye <ben.ye@bytedance.com>
This commit is contained in:
parent
6cc37f0a17
commit
9cd8326bb2
@ -88,7 +88,7 @@ func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapa
|
|||||||
// AddControllerServiceCapabilities stores the controller capabilities
|
// AddControllerServiceCapabilities stores the controller capabilities
|
||||||
// in driver object.
|
// in driver object.
|
||||||
func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) {
|
func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) {
|
||||||
var csc []*csi.ControllerServiceCapability
|
csc := make([]*csi.ControllerServiceCapability, 0, len(cl))
|
||||||
|
|
||||||
for _, c := range cl {
|
for _, c := range cl {
|
||||||
util.DefaultLog("Enabling controller service capability: %v", c.String())
|
util.DefaultLog("Enabling controller service capability: %v", c.String())
|
||||||
@ -101,7 +101,7 @@ func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceC
|
|||||||
// AddVolumeCapabilityAccessModes stores volume access modes.
|
// AddVolumeCapabilityAccessModes stores volume access modes.
|
||||||
func (d *CSIDriver) AddVolumeCapabilityAccessModes(
|
func (d *CSIDriver) AddVolumeCapabilityAccessModes(
|
||||||
vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode {
|
vc []csi.VolumeCapability_AccessMode_Mode) []*csi.VolumeCapability_AccessMode {
|
||||||
var vca []*csi.VolumeCapability_AccessMode
|
vca := make([]*csi.VolumeCapability_AccessMode, 0, len(vc))
|
||||||
for _, c := range vc {
|
for _, c := range vc {
|
||||||
util.DefaultLog("Enabling volume access mode: %v", c.String())
|
util.DefaultLog("Enabling volume access mode: %v", c.String())
|
||||||
vca = append(vca, NewVolumeCapabilityAccessMode(c))
|
vca = append(vca, NewVolumeCapabilityAccessMode(c))
|
||||||
|
Loading…
Reference in New Issue
Block a user