mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 05:53:03 +03:00
Optimize tryparse
* Don't check for null before * Don't try different formats when not needed (NumberFormat.Integer is the fast path)
This commit is contained in:
@@ -1143,7 +1143,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
public static string NormalizeTranscodingLevel(EncodingJobInfo state, string level)
|
||||
{
|
||||
if (double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out double requestLevel))
|
||||
if (double.TryParse(level, CultureInfo.InvariantCulture, out double requestLevel))
|
||||
{
|
||||
if (string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1737,7 +1737,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
else if (string.Equals(videoEncoder, "hevc_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// hevc_qsv use -level 51 instead of -level 153.
|
||||
if (double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out double hevcLevel))
|
||||
if (double.TryParse(level, CultureInfo.InvariantCulture, out double hevcLevel))
|
||||
{
|
||||
param += " -level " + (hevcLevel / 3);
|
||||
}
|
||||
@@ -1916,8 +1916,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
// If a specific level was requested, the source must match or be less than
|
||||
var level = state.GetRequestedLevel(videoStream.Codec);
|
||||
if (!string.IsNullOrEmpty(level)
|
||||
&& double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var requestLevel))
|
||||
if (double.TryParse(level, CultureInfo.InvariantCulture, out var requestLevel))
|
||||
{
|
||||
if (!videoStream.Level.HasValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user