aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2023-10-06 00:40:09 +0200
committerBond_009 <bond.009@outlook.com>2023-10-06 01:04:25 +0200
commitb176beb88e22a36cc056439ac2a4df4fbe68f2c1 (patch)
tree46988cc14ba7e8bdd9d6eb89588b1472f6caa25d /Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
parent40f7eb4e8cd9e250fb3870a4799a5a8d949e2068 (diff)
Reduce string allocations
Some simple changes to reduce the number of allocated strings
Diffstat (limited to 'Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs')
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 042422c6f..73861ff59 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -32,9 +32,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
return GetBook(args);
}
- var extension = Path.GetExtension(args.Path);
+ var extension = Path.GetExtension(args.Path.AsSpan());
- if (extension is not null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
+ if (_validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{
// It's a book
return new Book
@@ -51,12 +51,11 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
{
var bookFiles = args.FileSystemChildren.Where(f =>
{
- var fileExtension = Path.GetExtension(f.FullName)
- ?? string.Empty;
+ var fileExtension = Path.GetExtension(f.FullName.AsSpan());
return _validExtensions.Contains(
fileExtension,
- StringComparer.OrdinalIgnoreCase);
+ StringComparison.OrdinalIgnoreCase);
}).ToList();
// Don't return a Book if there is more (or less) than one document in the directory