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 /Emby.Naming | |
| 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 'Emby.Naming')
| -rw-r--r-- | Emby.Naming/Audio/AlbumParser.cs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Emby.Naming/Audio/AlbumParser.cs b/Emby.Naming/Audio/AlbumParser.cs index bbfdccc90..86a564153 100644 --- a/Emby.Naming/Audio/AlbumParser.cs +++ b/Emby.Naming/Audio/AlbumParser.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.IO; using System.Text.RegularExpressions; using Emby.Naming.Common; +using Jellyfin.Extensions; namespace Emby.Naming.Audio { @@ -58,13 +59,7 @@ namespace Emby.Naming.Audio var tmp = trimmedFilename.Slice(prefix.Length).Trim(); - int index = tmp.IndexOf(' '); - if (index != -1) - { - tmp = tmp.Slice(0, index); - } - - if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out _)) + if (int.TryParse(tmp.LeftPart(' '), CultureInfo.InvariantCulture, out _)) { return true; } |
