Merge pull request #45421 from allencloud/change-to-use-make-slice-to-store-objects

Automatic merge from submit-queue

use make slice to store objects to improve efficiency

Signed-off-by: allencloud <allen.sun@daocloud.io>



**What this PR does / why we need it**:

we we know the slice length in advance, I think we had better use make to create the specified length of slice. This will improve some kind of performance. Since if we create a slice with []type{}, we did not know how much space runtime should reserve, since slice implementation should be continuous in memory. While when we make a slice with specified length, runtime would reserve a continuous memory space which will not result in slice movement in case of current space is not enough.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
NONE

**Special notes for your reviewer**:
NONE

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2017-05-30 06:27:18 -07:00
committed by GitHub
5 changed files with 8 additions and 7 deletions

View File

@@ -342,7 +342,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeapi.Contai
imageID := toPullableImageID(r.Image, ir)
// Convert the mounts.
mounts := []*runtimeapi.Mount{}
mounts := make([]*runtimeapi.Mount, 0, len(r.Mounts))
for i := range r.Mounts {
m := r.Mounts[i]
readonly := !m.RW