diff options
| author | Marc Brooks <IDisposable@gmail.com> | 2026-08-04 05:27:25 -0500 |
|---|---|---|
| committer | Marc Brooks <IDisposable@gmail.com> | 2026-08-05 22:48:13 -0500 |
| commit | 234a49903b4424ebcbd7248739eaefeff0c7bd4d (patch) | |
| tree | 704da1f71cbe6fd2fe38abead5d6b4a29b1a75b4 | |
| parent | cd5962df50ab493cc3739e6a81f66627670b7c8b (diff) | |
Use a HashSet for existing items
Makes the test O(log n)
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs b/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs index 827c766449..7bd92b2e4b 100644 --- a/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs +++ b/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs @@ -257,14 +257,14 @@ public class ItemPersistenceService : IItemPersistenceService using var transaction = context.Database.BeginTransaction(); var ids = tuples.Select(f => f.Item.Id).ToArray(); - var existingItems = context.BaseItems.Where(e => ids.Contains(e.Id)).Select(f => f.Id).ToArray(); + var existingItems = context.BaseItems.Where(e => ids.Contains(e.Id)).Select(f => f.Id).ToHashSet(); foreach (var item in tuples) { var entity = BaseItemMapper.Map(item.Item, _appHost); entity.TopParentId = item.TopParent?.Id; - if (!existingItems.Any(e => e == entity.Id)) + if (!existingItems.Contains(entity.Id)) { context.BaseItems.Add(entity); } |
