diff --git a/src/TypeNameInterpretation/Delimiters.cs b/src/TypeNameInterpretation/Delimiters.cs index 9ff9d43..24d0030 100644 --- a/src/TypeNameInterpretation/Delimiters.cs +++ b/src/TypeNameInterpretation/Delimiters.cs @@ -8,6 +8,7 @@ static class Delimiters { #if NET public static SearchValues All { get; } = SearchValues.Create(_allDelimiterChars); + public static SearchValues AssemblySearch { get; } = SearchValues.Create(_allDelimiterChars.AsSpan(0, 5)); public static SearchValues Quote { get; } = SearchValues.Create(_allDelimiterChars.AsSpan(0, 2)); #else public static ReadOnlySpan All => _allDelimiterChars.AsSpan(); diff --git a/src/TypeNameInterpretation/InsParser.cs b/src/TypeNameInterpretation/InsParser.cs index 5de6cee..ff17049 100644 --- a/src/TypeNameInterpretation/InsParser.cs +++ b/src/TypeNameInterpretation/InsParser.cs @@ -323,6 +323,19 @@ int LocateStartOfAssembly(int index) while (index < _buffer.Length) { +#if NET + // Fast forward to the next meaningful char. + // This generally improves the performance in .NET Core but slows down .Net Framework. + var i = _buffer.Slice(index).IndexOfAny(Delimiters.AssemblySearch); + + if (i < 0) + { + return -1; + } + + index += i; +#endif + var c = _buffer[index]; if (c == '\\')