diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-02-19 16:52:29 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-02-19 16:52:29 +0100 |
| commit | 24a7e210c377bf828f21b5812f25c6545f7de006 (patch) | |
| tree | 0476ae141a3bfc3d597d438a316f8c20bdfaa3c8 /Jellyfin.Api/Helpers/StreamingHelpers.cs | |
| parent | 1deb9f36ba5822249b8359e311635ea9001d5635 (diff) | |
Optimize tryparse
* Don't check for null before
* Don't try different formats when not needed (NumberFormat.Integer is the fast path)
Diffstat (limited to 'Jellyfin.Api/Helpers/StreamingHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/StreamingHelpers.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index d867df86e..9b5a14c4d 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -337,10 +337,10 @@ public static class StreamingHelpers value = index == -1 ? value.Slice(npt.Length) : value.Slice(npt.Length, index - npt.Length); - if (value.IndexOf(':') == -1) + if (!value.Contains(':')) { // Parses npt times in the format of '417.33' - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds)) + if (double.TryParse(value, CultureInfo.InvariantCulture, out var seconds)) { return TimeSpan.FromSeconds(seconds).Ticks; } |
