Remove unnecessary array allocation

Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
This commit is contained in:
Dmitry Lyzo 2022-01-16 13:34:52 +03:00 committed by GitHub
parent 54549cd5b5
commit 60fe77c089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,15 +210,12 @@ namespace Jellyfin.Api.Controllers
if (item is IHasTrailers hasTrailers)
{
var trailers = hasTrailers.LocalTrailers;
var dtosTrailers = _dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item);
var allTrailers = new BaseItemDto[dtosTrailers.Count];
dtosTrailers.CopyTo(allTrailers, 0);
return allTrailers;
return Ok(_dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item));
}
return item.GetExtras(new[] { ExtraType.Trailer })
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
.ToArray();
return Ok(item.GetExtras()
.Where(e => e.ExtraType == ExtraType.Trailer)
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)));
}
/// <summary>