[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes to reduce allocations #848

Merged
merged 12 commits into from
Feb 20, 2019
Prev Previous commit
Next Next commit
Don't clone lists
  • Loading branch information
Bond-009 committed Feb 12, 2019
commit 3e6819c718a45b44eb3f84439d118ad849ccffa8
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public void SaveItem(BaseItem item, CancellationToken cancellationToken)
throw new ArgumentNullException(nameof(item));
}

SaveItems(new List<BaseItem> { item }, cancellationToken);
SaveItems(new [] { item }, cancellationToken);
}

public void SaveImages(BaseItem item)
Expand Down Expand Up @@ -576,7 +576,7 @@ public void SaveImages(BaseItem item)
/// or
/// cancellationToken
/// </exception>
public void SaveItems(List<BaseItem> items, CancellationToken cancellationToken)
public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
{
if (items == null)
{
Expand Down
12 changes: 5 additions & 7 deletions Emby.Server.Implementations/Library/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,18 +1806,16 @@ public void CreateItem(BaseItem item, BaseItem parent)
/// <returns>Task.</returns>
public void CreateItems(IEnumerable<BaseItem> items, BaseItem parent, CancellationToken cancellationToken)
{
var list = items.ToList();
JustAMan marked this conversation as resolved.
Show resolved Hide resolved

ItemRepository.SaveItems(list, cancellationToken);
ItemRepository.SaveItems(items, cancellationToken);

foreach (var item in list)
foreach (var item in items)
{
RegisterItem(item);
}

if (ItemAdded != null)
{
foreach (var item in list)
foreach (var item in items)
{
// With the live tv guide this just creates too much noise
if (item.SourceType != SourceType.Library)
Expand Down Expand Up @@ -1851,7 +1849,7 @@ public void UpdateImages(BaseItem item)
/// <summary>
/// Updates the item.
/// </summary>
public void UpdateItems(List<BaseItem> items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
public void UpdateItems(IEnumerable<BaseItem> items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
{
foreach (var item in items)
{
Expand Down Expand Up @@ -1906,7 +1904,7 @@ public void UpdateItems(List<BaseItem> items, BaseItem parent, ItemUpdateType up
/// <returns>Task.</returns>
public void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
{
UpdateItems(new List<BaseItem> { item }, parent, updateReason, cancellationToken);
UpdateItems(new [] { item }, parent, updateReason, cancellationToken);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Controller/Library/ILibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void AddParts(IEnumerable<IResolverIgnoreRule> rules,
/// <summary>
/// Updates the item.
/// </summary>
void UpdateItems(List<BaseItem> items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken);
void UpdateItems(IEnumerable<BaseItem> items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken);
void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Controller/Persistence/IItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IItemRepository : IRepository
/// </summary>
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
void SaveItems(List<BaseItem> items, CancellationToken cancellationToken);
void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);

void SaveImages(BaseItem item);

Expand Down