Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageVersion Include="Azure.Storage.Blobs" Version="12.21.2" />
<PackageVersion Include="Azure.Storage.Blobs.Batch" Version="12.18.1" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Composite" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="6.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ internal Enumerator(string path) =>
/// <summary>
/// Gets the current path component.
/// </summary>
public ReadOnlySpan<char> Current =>
public ReadOnlySpan<char> Current
{
//
// Using AsSpan(_start) followed by slicing is more efficient
// than AsSpan(_start, _count) because:
Expand All @@ -60,7 +61,9 @@ internal Enumerator(string path) =>
// which the JIT can't optimize away:
// (ulong)(uint)_start + (ulong)(uint)_count <= (ulong)(uint)Length
//
_path.AsSpan(_start)[.._count];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _path.AsSpan(_start)[.._count];
}

/// <summary>
/// Advances the enumerator to the next path component.
Expand Down
24 changes: 6 additions & 18 deletions src/Ramstack.FileSystem.Abstractions/VirtualPath.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

using Ramstack.FileSystem.Utilities;

Expand Down Expand Up @@ -168,28 +166,26 @@ public static bool IsNormalized(ReadOnlySpan<char> path)
{
var prior = path[0];

for (var j = 1; j < path.Length; j++)
for (var j = 1; (uint)j < (uint)path.Length; j++)
{
var ch = path[j];
if (ch == '\\' || ch == '/' && prior == '/')
return false;

if (ch == '.' && prior == '/')
{
if ((uint)j + 1 >= path.Length)
if ((uint)j + 1 >= (uint)path.Length)
return false;

var nch = path[j + 1];
if (nch == '/' || nch == '\\')
if (path[j + 1] is '/' or '\\')
return false;

if (nch == '.')
if (path[j + 1] == '.')
{
if ((uint)j + 2 >= path.Length)
if ((uint)j + 2 >= (uint)path.Length)
return false;

var sch = path[j + 2];
if (sch == '/' || sch == '\\')
if (path[j + 2] is '/' or '\\')
return false;
}
}
Expand Down Expand Up @@ -319,7 +315,6 @@ public static string Join(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2)
/// <see langword="true" /> if the path has a leading directory separator;
/// otherwise, <see langword="false" />.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasLeadingSlash(string path) =>
path.StartsWith('/') || path.StartsWith('\\');

Expand All @@ -331,7 +326,6 @@ public static bool HasLeadingSlash(string path) =>
/// <see langword="true" /> if the path has a trailing directory separator;
/// otherwise, <see langword="false" />.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasTrailingSlash(string path) =>
path.EndsWith('/') || path.EndsWith('\\');

Expand All @@ -343,7 +337,6 @@ public static bool HasTrailingSlash(string path) =>
/// <see langword="true" /> if the path has a leading directory separator;
/// otherwise, <see langword="false" />.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasLeadingSlash(ReadOnlySpan<char> path)
{
if (path.Length != 0)
Expand All @@ -364,7 +357,6 @@ public static bool HasLeadingSlash(ReadOnlySpan<char> path)
/// <see langword="true" /> if the path has a trailing directory separator;
/// otherwise, <see langword="false" />.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasTrailingSlash(ReadOnlySpan<char> path)
{
if (path.Length != 0)
Expand Down Expand Up @@ -392,8 +384,4 @@ private static int GetDirectoryNameOffset(ReadOnlySpan<char> path)

return index;
}

[DoesNotReturn]
private static void Error_InvalidPath() =>
throw new ArgumentException("Invalid path");
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" />
<PackageReference Include="Microsoft.SourceLink.GitHub">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/Ramstack.FileSystem.Globbing/GlobbingFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public GlobbingFileSystem(IVirtualFileSystem fileSystem, string[] patterns, stri
ArgumentNullException.ThrowIfNull(patterns);

_fs = fileSystem;
_patterns = patterns.ToArray();
_excludes = excludes?.ToArray() ?? [];
_patterns = [..patterns];
_excludes = [..excludes ?? []];
}

/// <inheritdoc />
Expand Down