aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/StreamingHelpers.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 /Jellyfin.Api/Helpers/StreamingHelpers.cs
parent40f7eb4e8cd9e250fb3870a4799a5a8d949e2068 (diff)
Reduce string allocations
Some simple changes to reduce the number of allocated strings
Diffstat (limited to 'Jellyfin.Api/Helpers/StreamingHelpers.cs')
-rw-r--r--Jellyfin.Api/Helpers/StreamingHelpers.cs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index 782cd6568..d15fe4fab 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -243,7 +243,7 @@ public static class StreamingHelpers
? GetOutputFileExtension(state, mediaSource)
: ("." + state.OutputContainer);
- state.OutputFilePath = GetOutputFilePath(state, ext!, serverConfigurationManager, streamingRequest.DeviceId, streamingRequest.PlaySessionId);
+ state.OutputFilePath = GetOutputFilePath(state, ext, serverConfigurationManager, streamingRequest.DeviceId, streamingRequest.PlaySessionId);
return state;
}
@@ -418,11 +418,11 @@ public static class StreamingHelpers
/// <returns>System.String.</returns>
private static string? GetOutputFileExtension(StreamState state, MediaSourceInfo? mediaSource)
{
- var ext = Path.GetExtension(state.RequestedUrl);
+ var ext = Path.GetExtension(state.RequestedUrl.AsSpan());
- if (!string.IsNullOrEmpty(ext))
+ if (ext.IsEmpty)
{
- return ext;
+ return null;
}
// Try to infer based on the desired video codec
@@ -504,7 +504,7 @@ public static class StreamingHelpers
/// <param name="deviceId">The device id.</param>
/// <param name="playSessionId">The play session id.</param>
/// <returns>The complete file path, including the folder, for the transcoding file.</returns>
- private static string GetOutputFilePath(StreamState state, string outputFileExtension, IServerConfigurationManager serverConfigurationManager, string? deviceId, string? playSessionId)
+ private static string GetOutputFilePath(StreamState state, string? outputFileExtension, IServerConfigurationManager serverConfigurationManager, string? deviceId, string? playSessionId)
{
var data = $"{state.MediaPath}-{state.UserAgent}-{deviceId!}-{playSessionId!}";