mirror of
https://github.com/Radarr/Radarr
synced 2026-04-26 09:41:40 +02:00
perf: use char overloads for StartsWith/EndsWith (S6610)
Use single character overloads instead of single-character string overloads for better performance.
This commit is contained in:
parent
6b67a1672c
commit
021fd9b55e
9 changed files with 15 additions and 15 deletions
|
|
@ -42,7 +42,7 @@ public OsPath(string path, OsPathKind kind)
|
|||
|
||||
private static OsPathKind DetectPathKind(string path)
|
||||
{
|
||||
if (path.StartsWith("/"))
|
||||
if (path.StartsWith('/'))
|
||||
{
|
||||
return OsPathKind.Unix;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ public bool IsRooted
|
|||
|
||||
if (IsUnixPath)
|
||||
{
|
||||
return _path.StartsWith("/");
|
||||
return _path.StartsWith('/');
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -246,7 +246,7 @@ private int GetFileNameIndex()
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (_path.StartsWith("/") && index == 0)
|
||||
if (_path.StartsWith('/') && index == 0)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ public bool Equals(OsPath other, bool ignoreTrailingSlash)
|
|||
newFragments.Add(leftFragments[j]);
|
||||
}
|
||||
|
||||
if (left.FullPath.EndsWith("\\") || left.FullPath.EndsWith("/"))
|
||||
if (left.FullPath.EndsWith("\\") || left.FullPath.EndsWith('/'))
|
||||
{
|
||||
newFragments.Add(string.Empty);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ private static bool IsPathValidForWindows(string path)
|
|||
|
||||
private static bool IsPathValidForNonWindows(string path)
|
||||
{
|
||||
return path.StartsWith("/");
|
||||
return path.StartsWith('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public static bool IsValidUrl(this string path)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (path.StartsWith(" ") || path.EndsWith(" "))
|
||||
if (path.StartsWith(' ') || path.EndsWith(' '))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public static string BuildBaseUrl(bool useHttps, string host, int port, string u
|
|||
{
|
||||
var protocol = useHttps ? "https" : "http";
|
||||
|
||||
if (urlBase.IsNotNullOrWhiteSpace() && !urlBase.StartsWith("/"))
|
||||
if (urlBase.IsNotNullOrWhiteSpace() && !urlBase.StartsWith('/'))
|
||||
{
|
||||
urlBase = "/" + urlBase;
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ protected virtual void ApplyFormData(HttpRequest request)
|
|||
|
||||
public virtual HttpRequestBuilder Resource(string resourceUrl)
|
||||
{
|
||||
if (!ResourceUrl.IsNotNullOrWhiteSpace() || resourceUrl.StartsWith("/"))
|
||||
if (!ResourceUrl.IsNotNullOrWhiteSpace() || resourceUrl.StartsWith('/'))
|
||||
{
|
||||
ResourceUrl = resourceUrl.TrimStart('/');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public HttpUri(string scheme, string host, int? port, string path, string query,
|
|||
|
||||
if (path.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
if (host.IsNotNullOrWhiteSpace() || path.StartsWith("/"))
|
||||
if (host.IsNotNullOrWhiteSpace() || path.StartsWith('/'))
|
||||
{
|
||||
builder.Append('/');
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ private static string CombineRelativePath(string basePath, string relativePath)
|
|||
return basePath;
|
||||
}
|
||||
|
||||
if (relativePath.StartsWith("/"))
|
||||
if (relativePath.StartsWith('/'))
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ private IEnumerable<ImportListRequest> GetMovies(string searchParameters)
|
|||
var urlBase = "";
|
||||
if (!string.IsNullOrWhiteSpace(Settings.UrlBase))
|
||||
{
|
||||
urlBase = Settings.UrlBase.StartsWith("/") ? Settings.UrlBase : $"/{Settings.UrlBase}";
|
||||
urlBase = Settings.UrlBase.StartsWith('/') ? Settings.UrlBase : $"/{Settings.UrlBase}";
|
||||
}
|
||||
|
||||
var status = "";
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ private void ValidateMapping(List<RemotePathMapping> existing, RemotePathMapping
|
|||
throw new ArgumentException("Invalid Host");
|
||||
}
|
||||
|
||||
if (mapping.RemotePath.StartsWith(" "))
|
||||
if (mapping.RemotePath.StartsWith(' '))
|
||||
{
|
||||
throw new ArgumentException("Remote Path must not start with a space");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ private IMount ParseLine(string line)
|
|||
var type = split[2];
|
||||
var options = ParseOptions(split[3]);
|
||||
|
||||
if (!mount.StartsWith("/"))
|
||||
if (!mount.StartsWith('/'))
|
||||
{
|
||||
// Possible a namespace like 'net:[1234]'.
|
||||
// But we just filter anything not starting with /, we're not interested in anything that isn't mounted somewhere.
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ public RemotePathMappingController(IRemotePathMappingService remotePathMappingSe
|
|||
.NotEmpty();
|
||||
|
||||
SharedValidator.RuleFor(c => c.RemotePath)
|
||||
.Must(remotePath => remotePath.IsNotNullOrWhiteSpace() && !remotePath.StartsWith(" "))
|
||||
.Must(remotePath => remotePath.IsNotNullOrWhiteSpace() && !remotePath.StartsWith(' '))
|
||||
.WithMessage("Remote Path '{PropertyValue}' must not start with a space");
|
||||
|
||||
SharedValidator.RuleFor(c => c.RemotePath)
|
||||
.Must(remotePath => remotePath.IsNotNullOrWhiteSpace() && !remotePath.EndsWith(" "))
|
||||
.Must(remotePath => remotePath.IsNotNullOrWhiteSpace() && !remotePath.EndsWith(' '))
|
||||
.WithMessage("Remote Path '{PropertyValue}' must not end with a space");
|
||||
|
||||
SharedValidator.RuleFor(c => c.LocalPath)
|
||||
|
|
|
|||
Loading…
Reference in a new issue