mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 21:33:02 +02:00
Use stackalloc in Format3DParser.Parse
This commit is contained in:
parent
9111730a0a
commit
66de842896
|
@ -17,17 +17,17 @@ namespace Emby.Naming.Video
|
||||||
/// <param name="path">Path to file.</param>
|
/// <param name="path">Path to file.</param>
|
||||||
/// <param name="namingOptions">The naming options.</param>
|
/// <param name="namingOptions">The naming options.</param>
|
||||||
/// <returns>Returns <see cref="Format3DResult"/> object.</returns>
|
/// <returns>Returns <see cref="Format3DResult"/> object.</returns>
|
||||||
public static Format3DResult Parse(string path, NamingOptions namingOptions)
|
public static Format3DResult Parse(ReadOnlySpan<char> path, NamingOptions namingOptions)
|
||||||
{
|
{
|
||||||
int oldLen = namingOptions.VideoFlagDelimiters.Length;
|
int oldLen = namingOptions.VideoFlagDelimiters.Length;
|
||||||
var delimiters = new char[oldLen + 1];
|
Span<char> delimiters = stackalloc char[oldLen + 1];
|
||||||
namingOptions.VideoFlagDelimiters.CopyTo(delimiters, 0);
|
namingOptions.VideoFlagDelimiters.AsSpan().CopyTo(delimiters);
|
||||||
delimiters[oldLen] = ' ';
|
delimiters[oldLen] = ' ';
|
||||||
|
|
||||||
return Parse(path, delimiters, namingOptions);
|
return Parse(path, delimiters, namingOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Format3DResult Parse(ReadOnlySpan<char> path, char[] delimiters, NamingOptions namingOptions)
|
private static Format3DResult Parse(ReadOnlySpan<char> path, ReadOnlySpan<char> delimiters, NamingOptions namingOptions)
|
||||||
{
|
{
|
||||||
foreach (var rule in namingOptions.Format3DRules)
|
foreach (var rule in namingOptions.Format3DRules)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace Emby.Naming.Video
|
||||||
return _defaultResult;
|
return _defaultResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Format3DResult Parse(ReadOnlySpan<char> path, Format3DRule rule, char[] delimiters)
|
private static Format3DResult Parse(ReadOnlySpan<char> path, Format3DRule rule, ReadOnlySpan<char> delimiters)
|
||||||
{
|
{
|
||||||
bool is3D = false;
|
bool is3D = false;
|
||||||
string? format3D = null;
|
string? format3D = null;
|
||||||
|
|
Loading…
Reference in a new issue