preallocate array

This commit is contained in:
Shreyas Goenka 2023-05-26 13:02:50 +02:00
parent 8a9175e332
commit 7c46b35597
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 8 additions and 8 deletions

View File

@ -143,14 +143,14 @@ func (w *WorkspaceFilesClient) ReadDir(ctx context.Context, name string) ([]File
return nil, err return nil, err
} }
info := make([]FileInfo, 0) info := make([]FileInfo, len(objects))
for _, i := range objects { for i, v := range objects {
info = append(info, FileInfo{ info[i] = FileInfo{
Type: string(i.ObjectType), Type: string(v.ObjectType),
Name: path.Base(i.Path), Name: path.Base(v.Path),
Size: i.Size, Size: v.Size,
ModTime: time.UnixMilli(i.ModifiedAt), ModTime: time.UnixMilli(v.ModifiedAt),
}) }
} }
return info, nil return info, nil
} }