Skip to content

Commit 0fa747a

Browse files
authored
Replace OptimizedInboxTextEncoder vectorization with SearchValues (#114494)
1 parent 72a4c86 commit 0fa747a

File tree

7 files changed

+52
-673
lines changed

7 files changed

+52
-673
lines changed

src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ System.Text.Encodings.Web.JavaScriptEncoder</PackageDescription>
5353
<Compile Include="System\ThrowHelper.cs" />
5454
</ItemGroup>
5555

56-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
57-
<Compile Include="System\Text\Encodings\Web\OptimizedInboxTextEncoder.Ssse3.cs" />
58-
<Compile Include="System\Text\Encodings\Web\OptimizedInboxTextEncoder.AdvSimd64.cs" />
59-
</ItemGroup>
60-
6156
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
6257
<Compile Include="$(CoreLibSharedDir)System\Text\Rune.cs" Link="System\Text\Rune.cs" />
6358
<Compile Include="$(CoreLibSharedDir)System\Text\Unicode\Utf16Utility.cs" Link="System\Text\Unicode\Utf16Utility.cs" />

src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.AdvSimd64.cs

Lines changed: 0 additions & 257 deletions
This file was deleted.

src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,11 @@
33

44
using System.Diagnostics;
55
using System.Runtime.CompilerServices;
6-
using System.Runtime.InteropServices;
7-
8-
#if NET
9-
using System.Runtime.Intrinsics;
10-
#endif
116

127
namespace System.Text.Encodings.Web
138
{
149
internal sealed partial class OptimizedInboxTextEncoder
1510
{
16-
/// <summary>
17-
/// A bitmap which represents allowed ASCII code points.
18-
/// </summary>
19-
[StructLayout(LayoutKind.Explicit)]
20-
private unsafe partial struct AllowedAsciiCodePoints
21-
{
22-
[FieldOffset(0)] // ensure same offset with AsVector field
23-
private fixed byte AsBytes[16];
24-
25-
#if NET
26-
#if !TARGET_BROWSER
27-
[FieldOffset(0)] // ensure same offset with AsBytes field
28-
internal Vector128<byte> AsVector;
29-
#else
30-
// This member shouldn't be accessed from browser-based code paths.
31-
// All call sites should be trimmed away, which will also trim this member
32-
// and the type hierarchy it links to.
33-
#pragma warning disable CA1822
34-
internal Vector128<byte> AsVector => throw new PlatformNotSupportedException();
35-
#pragma warning restore CA1822
36-
#endif
37-
#endif
38-
39-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
40-
internal readonly bool IsAllowedAsciiCodePoint(uint codePoint)
41-
{
42-
if (codePoint > 0x7F)
43-
{
44-
return false; // non-ASCII
45-
}
46-
47-
uint mask = AsBytes[codePoint & 0xF];
48-
if ((mask & (0x1u << (int)(codePoint >> 4))) == 0)
49-
{
50-
return false; // ASCII but disallowed
51-
}
52-
53-
return true;
54-
}
55-
56-
internal void PopulateAllowedCodePoints(in AllowedBmpCodePointsBitmap allowedBmpCodePoints)
57-
{
58-
this = default; // clear all existing data
59-
60-
// we only care about ASCII non-control chars; all control chars and non-ASCII chars are disallowed
61-
for (int i = 0x20; i < 0x7F; i++)
62-
{
63-
if (allowedBmpCodePoints.IsCharAllowed((char)i))
64-
{
65-
AsBytes[i & 0xF] |= (byte)(1 << (i >> 4));
66-
}
67-
}
68-
}
69-
}
70-
7111
/// <summary>
7212
/// A bitmap which represents the 64-bit pre-escaped form of the ASCII code points.
7313
/// A pre-escaped code point has the form [ WW 00 FF EE DD CC BB AA ],

0 commit comments

Comments
 (0)