diff options
| author | Andrew Mahone <andrew.mahone@gmail.com> | 2019-11-05 14:53:46 -0500 |
|---|---|---|
| committer | Andrew Mahone <andrew.mahone@gmail.com> | 2019-11-05 14:53:46 -0500 |
| commit | 8505ee9d6c0b2f073fd39c538cbdb0ee9ee95354 (patch) | |
| tree | 88083ada7a4c5c92920105e1d802f09c881e2fa5 /Emby.Server.Implementations/Data/SqliteItemRepository.cs | |
| parent | cc7741efd4c3b7c2c9039c768fc1a9e1442dbf8d (diff) | |
Extract the prefix for MediaAttachment insertions to a static member instead of generating it per-query.
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteItemRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/SqliteItemRepository.cs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 2b9c6a52f..dd8620f9f 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -51,6 +51,19 @@ namespace Emby.Server.Implementations.Data private readonly TypeMapper _typeMapper; private readonly JsonSerializerOptions _jsonOptions; + static SqliteItemRepository() { + var queryPrefixText = new StringBuilder(); + queryPrefixText.Append("insert into mediaattachments ("); + foreach (var column in _mediaAttachmentSaveColumns) + { + queryPrefixText.Append(column); + queryPrefixText.Append(','); + } + queryPrefixText.Length -= 1; + queryPrefixText.Append(") values "); + _mediaAttachmentInsertPrefix = queryPrefixText.ToString(); + } + /// <summary> /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class. /// </summary> @@ -436,6 +449,7 @@ namespace Emby.Server.Implementations.Data "Filename", "MIMEType" }; + private static readonly string _mediaAttachmentInsertPrefix; private static string GetSaveItemCommandText() { @@ -6223,7 +6237,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type while (startIndex < attachments.Count) { - var insertText = new StringBuilder(string.Format("insert into mediaattachments ({0}) values ", string.Join(",", _mediaAttachmentSaveColumns))); + var insertText = new StringBuilder(_mediaAttachmentInsertPrefix); var endIndex = Math.Min(attachments.Count, startIndex + insertAtOnce); |
