-
-
Notifications
You must be signed in to change notification settings - Fork 886
Remove obsolete code #2189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove obsolete code #2189
Changes from 10 commits
eee64f2
6fc84a8
ca0b284
3fb4787
3c40500
3d837b1
606e64a
89faddf
61299f9
65a2ea3
ba1adc3
3031400
f9c9a01
1c5a78c
3a6f26d
b22785e
ac84e49
90c85c0
0e46510
e25734a
9b29319
145dc9e
e9049e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <RuleSet Name="ImageSharp" ToolsVersion="17.0"> | ||
| <Include Path="..\shared-infrastructure\sixlabors.ruleset" Action="Default" /> | ||
| <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> | ||
| <Rule Id="SA1011" Action="None" /> | ||
| </Rules> | ||
| </RuleSet> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,8 @@ | |
| using System.Numerics; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
| #if SUPPORTS_RUNTIME_INTRINSICS | ||
| using System.Runtime.Intrinsics; | ||
| using System.Runtime.Intrinsics.X86; | ||
| #endif | ||
|
|
||
| namespace SixLabors.ImageSharp.ColorSpaces.Companding | ||
| { | ||
|
|
@@ -25,10 +23,10 @@ public static class SRgbCompanding | |
| private const int Length = Scale + 2; // 256kb @ 16bit precision. | ||
| private const int Scale = (1 << 16) - 1; | ||
|
|
||
| private static readonly Lazy<float[]> LazyCompressTable = new Lazy<float[]>( | ||
| private static readonly Lazy<float[]> LazyCompressTable = new( | ||
| () => | ||
| { | ||
| var result = new float[Length]; | ||
| float[] result = new float[Length]; | ||
|
|
||
| for (int i = 0; i < result.Length; i++) | ||
| { | ||
|
|
@@ -49,10 +47,10 @@ public static class SRgbCompanding | |
| }, | ||
| true); | ||
|
|
||
| private static readonly Lazy<float[]> LazyExpandTable = new Lazy<float[]>( | ||
| private static readonly Lazy<float[]> LazyExpandTable = new( | ||
| () => | ||
| { | ||
| var result = new float[Length]; | ||
| float[] result = new float[Length]; | ||
|
|
||
| for (int i = 0; i < result.Length; i++) | ||
| { | ||
|
|
@@ -84,19 +82,17 @@ public static class SRgbCompanding | |
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static void Expand(Span<Vector4> vectors) | ||
| { | ||
| #if SUPPORTS_RUNTIME_INTRINSICS | ||
| if (Avx2.IsSupported && vectors.Length >= 2) | ||
| { | ||
| CompandAvx2(vectors, ExpandTable); | ||
|
|
||
| if (Numerics.Modulo2(vectors.Length) != 0) | ||
| { | ||
| // Vector4 fits neatly in pairs. Any overlap has to be equal to 1. | ||
| Expand(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1))); | ||
| Expand(ref MemoryMarshal.GetReference(vectors[^1..])); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old version may be more performant, unfortunately. This is tracked in dotnet/roslyn#43598, and you can see the difference in this sharplab.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦♂️ This is so frustrating. Why introduce an analyser that promotes worse behaviour? |
||
| } | ||
| } | ||
| else | ||
| #endif | ||
| { | ||
| CompandScalar(vectors, ExpandTable); | ||
| } | ||
|
|
@@ -109,19 +105,17 @@ public static void Expand(Span<Vector4> vectors) | |
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static unsafe void Compress(Span<Vector4> vectors) | ||
| { | ||
| #if SUPPORTS_RUNTIME_INTRINSICS | ||
| if (Avx2.IsSupported && vectors.Length >= 2) | ||
| { | ||
| CompandAvx2(vectors, CompressTable); | ||
|
|
||
| if (Numerics.Modulo2(vectors.Length) != 0) | ||
| { | ||
| // Vector4 fits neatly in pairs. Any overlap has to be equal to 1. | ||
| Compress(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1))); | ||
| Compress(ref MemoryMarshal.GetReference(vectors[^1..])); | ||
| } | ||
| } | ||
| else | ||
| #endif | ||
| { | ||
| CompandScalar(vectors, CompressTable); | ||
| } | ||
|
|
@@ -171,8 +165,6 @@ public static float Expand(float channel) | |
| public static float Compress(float channel) | ||
| => channel <= 0.0031308F ? 12.92F * channel : (1.055F * MathF.Pow(channel, 0.416666666666667F)) - 0.055F; | ||
|
|
||
| #if SUPPORTS_RUNTIME_INTRINSICS | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| private static unsafe void CompandAvx2(Span<Vector4> vectors, float[] table) | ||
| { | ||
|
|
@@ -204,7 +196,6 @@ private static unsafe void CompandAvx2(Span<Vector4> vectors, float[] table) | |
| } | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| private static unsafe void CompandScalar(Span<Vector4> vectors, float[] table) | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to only use forward slashes now because Windows now also supports that.