Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add MemoryExtensions to CoreLib along with necessary SpanHelpers #16521

Merged
merged 10 commits into from
Feb 27, 2018
5 changes: 4 additions & 1 deletion src/mscorlib/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3715,4 +3715,7 @@
<data name="Argument_InvalidGenericInstantiation" xml:space="preserve">
<value>The given generic instantiation was invalid.</value>
</data>
</root>
<data name="Argument_OverlapAlignmentMismatch" xml:space="preserve">
<value>Overlapping spans have mismatching alignment.</value>
</data>
</root>
8 changes: 7 additions & 1 deletion src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
<Compile Include="$(MSBuildThisFileDirectory)System\MemberAccessException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Memory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MemoryDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MemoryExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MemoryExtensions.Fast.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MethodAccessException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MidpointRounding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\MissingMethodException.cs" />
Expand Down Expand Up @@ -485,8 +487,12 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Single.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Span.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Span.Fast.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Span.NonGeneric.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanDebugView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.BinarySearch.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.Byte.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.T.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\String.Manipulation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\String.Searching.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\StringSpanHelpers.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/shared/System/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFor
bool success = Number.TryParseDouble(s, style, info, out result);
if (!success)
{
ReadOnlySpan<char> sTrim = StringSpanHelpers.Trim(s);
ReadOnlySpan<char> sTrim = s.Trim();
if (StringSpanHelpers.Equals(sTrim, info.PositiveInfinitySymbol))
{
result = PositiveInfinity;
Expand Down
540 changes: 540 additions & 0 deletions src/mscorlib/shared/System/MemoryExtensions.Fast.cs

Large diffs are not rendered by default.

1,170 changes: 1,170 additions & 0 deletions src/mscorlib/shared/System/MemoryExtensions.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/mscorlib/shared/System/Span.Fast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ public void Clear()
{
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
{
Span.ClearWithReferences(ref Unsafe.As<T, IntPtr>(ref _pointer.Value), (nuint)_length * (nuint)(Unsafe.SizeOf<T>() / sizeof(nuint)));
SpanHelpers.ClearWithReferences(ref Unsafe.As<T, IntPtr>(ref _pointer.Value), (nuint)_length * (nuint)(Unsafe.SizeOf<T>() / sizeof(nuint)));
}
else
{
Span.ClearWithoutReferences(ref Unsafe.As<T, byte>(ref _pointer.Value), (nuint)_length * (nuint)Unsafe.SizeOf<T>());
SpanHelpers.ClearWithoutReferences(ref Unsafe.As<T, byte>(ref _pointer.Value), (nuint)_length * (nuint)Unsafe.SizeOf<T>());
}
}

Expand Down
Loading