Use string.Split(char) where possible instead of string.Split(char[])
This commit is contained in:
parent
569874a212
commit
bc7359f87d
|
@ -18,7 +18,7 @@ namespace Emby.Dlna.Didl
|
||||||
{
|
{
|
||||||
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
|
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
_fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
_fields = (filter ?? string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(string field)
|
public bool Contains(string field)
|
||||||
|
|
|
@ -1032,7 +1032,7 @@ namespace Emby.Server.Implementations
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No metafile, so lets see if the folder is versioned.
|
// No metafile, so lets see if the folder is versioned.
|
||||||
metafile = dir.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries)[^1];
|
metafile = dir.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)[^1];
|
||||||
|
|
||||||
int versionIndex = dir.LastIndexOf('_');
|
int versionIndex = dir.LastIndexOf('_');
|
||||||
if (versionIndex != -1 && Version.TryParse(dir.Substring(versionIndex + 1), out Version parsedVersion))
|
if (versionIndex != -1 && Version.TryParse(dir.Substring(versionIndex + 1), out Version parsedVersion))
|
||||||
|
|
|
@ -1007,7 +1007,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = value.Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
|
@ -1057,7 +1057,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = value.Split('|' , StringSplitOptions.RemoveEmptyEntries);
|
||||||
var list = new List<ItemImageInfo>();
|
var list = new List<ItemImageInfo>();
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
|
@ -1096,7 +1096,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
||||||
{
|
{
|
||||||
var parts = value.Split(new[] { '*' }, StringSplitOptions.None);
|
var parts = value.Split('*', StringSplitOptions.None);
|
||||||
|
|
||||||
if (parts.Length < 3)
|
if (parts.Length < 3)
|
||||||
{
|
{
|
||||||
|
@ -1532,7 +1532,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Genres = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Genres = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1593,7 +1593,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
IEnumerable<MetadataField> GetLockedFields(string s)
|
IEnumerable<MetadataField> GetLockedFields(string s)
|
||||||
{
|
{
|
||||||
foreach (var i in s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
||||||
{
|
{
|
||||||
|
@ -1612,7 +1612,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Studios = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Studios = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1622,7 +1622,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Tags = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Tags = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1636,7 +1636,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
IEnumerable<TrailerType> GetTrailerTypes(string s)
|
IEnumerable<TrailerType> GetTrailerTypes(string s)
|
||||||
{
|
{
|
||||||
foreach (var i in s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
||||||
{
|
{
|
||||||
|
@ -1811,7 +1811,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.ProductionLocations = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
|
item.ProductionLocations = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1848,14 +1848,14 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (item is IHasArtist hasArtists && !reader.IsDBNull(index))
|
if (item is IHasArtist hasArtists && !reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
hasArtists.Artists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
hasArtists.Artists = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (item is IHasAlbumArtist hasAlbumArtists && !reader.IsDBNull(index))
|
if (item is IHasAlbumArtist hasAlbumArtists && !reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
hasAlbumArtists.AlbumArtists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
hasAlbumArtists.AlbumArtists = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -5611,7 +5611,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allTypes = typeString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
var allTypes = typeString.Split('|', StringSplitOptions.RemoveEmptyEntries)
|
||||||
.ToLookup(x => x);
|
.ToLookup(x => x);
|
||||||
|
|
||||||
foreach (var type in allTypes)
|
foreach (var type in allTypes)
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Dto
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var containers = container.Split(new[] { ',' });
|
var containers = container.Split(',');
|
||||||
if (containers.Length < 2)
|
if (containers.Length < 2)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = authorizationHeader.Split(new[] { ' ' }, 2);
|
var parts = authorizationHeader.Split(' ', 2);
|
||||||
|
|
||||||
// There should be at least to parts
|
// There should be at least to parts
|
||||||
if (parts.Length != 2)
|
if (parts.Length != 2)
|
||||||
|
@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
|
|
||||||
foreach (var item in parts)
|
foreach (var item in parts)
|
||||||
{
|
{
|
||||||
var param = item.Trim().Split(new[] { '=' }, 2);
|
var param = item.Trim().Split('=', 2);
|
||||||
|
|
||||||
if (param.Length == 2)
|
if (param.Length == 2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -849,7 +849,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
throw new ArgumentException("Key can't be empty.", nameof(key));
|
throw new ArgumentException("Key can't be empty.", nameof(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
var keys = key.Split(new[] { LiveStreamIdDelimeter }, 2);
|
var keys = key.Split(LiveStreamIdDelimeter, 2);
|
||||||
|
|
||||||
var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), keys[0], StringComparison.OrdinalIgnoreCase));
|
var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), keys[0], StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
|
|
@ -2208,7 +2208,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public Task ResetTuner(string id, CancellationToken cancellationToken)
|
public Task ResetTuner(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var parts = id.Split(new[] { '_' }, 2);
|
var parts = id.Split('_', 2);
|
||||||
|
|
||||||
var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), parts[0], StringComparison.OrdinalIgnoreCase));
|
var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), parts[0], StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace Jellyfin.Api.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeEmpty
|
return removeEmpty
|
||||||
? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
|
? value.Split(separator, StringSplitOptions.RemoveEmptyEntries)
|
||||||
: value.Split(separator);
|
: value.Split(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace MediaBrowser.Common.Json.Converters
|
||||||
{
|
{
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
if (reader.TokenType == JsonTokenType.String)
|
||||||
{
|
{
|
||||||
var stringEntries = reader.GetString()?.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
var stringEntries = reader.GetString()?.Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (stringEntries == null || stringEntries.Length == 0)
|
if (stringEntries == null || stringEntries.Length == 0)
|
||||||
{
|
{
|
||||||
return Array.Empty<T>();
|
return Array.Empty<T>();
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
else if (part.StartsWith("fps=", StringComparison.OrdinalIgnoreCase))
|
else if (part.StartsWith("fps=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var rate = part.Split(new[] { '=' }, 2)[^1];
|
var rate = part.Split('=', 2)[^1];
|
||||||
|
|
||||||
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val))
|
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val))
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
else if (state.RunTimeTicks.HasValue &&
|
else if (state.RunTimeTicks.HasValue &&
|
||||||
part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
|
part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var time = part.Split(new[] { '=' }, 2).Last();
|
var time = part.Split('=', 2)[^1];
|
||||||
|
|
||||||
if (TimeSpan.TryParse(time, _usCulture, out var val))
|
if (TimeSpan.TryParse(time, _usCulture, out var val))
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
else if (part.StartsWith("size=", StringComparison.OrdinalIgnoreCase))
|
else if (part.StartsWith("size=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var size = part.Split(new[] { '=' }, 2).Last();
|
var size = part.Split('=', 2)[^1];
|
||||||
|
|
||||||
int? scale = null;
|
int? scale = null;
|
||||||
if (size.IndexOf("kb", StringComparison.OrdinalIgnoreCase) != -1)
|
if (size.IndexOf("kb", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
|
@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
else if (part.StartsWith("bitrate=", StringComparison.OrdinalIgnoreCase))
|
else if (part.StartsWith("bitrate=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var rate = part.Split(new[] { '=' }, 2).Last();
|
var rate = part.Split('=', 2)[^1];
|
||||||
|
|
||||||
int? scale = null;
|
int? scale = null;
|
||||||
if (rate.IndexOf("kbits/s", StringComparison.OrdinalIgnoreCase) != -1)
|
if (rate.IndexOf("kbits/s", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
string subtitleId,
|
string subtitleId,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var parts = subtitleId.Split(new[] { '_' }, 2);
|
var parts = subtitleId.Split('_', 2);
|
||||||
var provider = GetProvider(parts[0]);
|
var provider = GetProvider(parts[0]);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -329,7 +329,7 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
Index = index,
|
Index = index,
|
||||||
ItemId = item.Id,
|
ItemId = item.Id,
|
||||||
Type = MediaStreamType.Subtitle
|
Type = MediaStreamType.Subtitle
|
||||||
}).First();
|
})[0];
|
||||||
|
|
||||||
var path = stream.Path;
|
var path = stream.Path;
|
||||||
_monitor.ReportFileSystemChangeBeginning(path);
|
_monitor.ReportFileSystemChangeBeginning(path);
|
||||||
|
@ -349,10 +349,10 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<SubtitleResponse> GetRemoteSubtitles(string id, CancellationToken cancellationToken)
|
public Task<SubtitleResponse> GetRemoteSubtitles(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var parts = id.Split(new[] { '_' }, 2);
|
var parts = id.Split('_', 2);
|
||||||
|
|
||||||
var provider = GetProvider(parts[0]);
|
var provider = GetProvider(parts[0]);
|
||||||
id = parts.Last();
|
id = parts[1];
|
||||||
|
|
||||||
return provider.GetSubtitles(id, cancellationToken);
|
return provider.GetSubtitles(id, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user