Skip to content
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 unused variables and methods #963

Merged
merged 8 commits into from
Aug 11, 2019
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
38 changes: 1 addition & 37 deletions src/ImageSharp/Advanced/AdvancedImageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -153,42 +153,6 @@ internal static Memory<TPixel> GetPixelRowMemory<TPixel>(this Image<TPixel> sour
internal static MemoryAllocator GetMemoryAllocator(this IConfigurable source)
=> GetConfiguration(source).MemoryAllocator;

/// <summary>
/// Gets the span to the backing buffer.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The span returned from Pixel source</returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.PixelBuffer.GetSpan();

/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span returned from Pixel source
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> GetSpan(source.PixelBuffer, row);

/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span returned from Pixel source.
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(Buffer2D<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> source.GetSpan().Slice(row * source.Width, source.Width);

/// <summary>
/// Gets the configuration.
/// </summary>
Expand Down
24 changes: 1 addition & 23 deletions src/ImageSharp/Common/Helpers/Guard.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -51,28 +51,6 @@ public static void NotNullOrWhiteSpace(string value, string parameterName)
}
}

/// <summary>
/// Ensures that the enumeration is not null or empty.
/// </summary>
/// <typeparam name="T">The type of objects in the <paramref name="value"/></typeparam>
/// <param name="value">The target enumeration, which should be checked against being null or empty.</param>
/// <param name="parameterName">Name of the parameter.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="value"/> is empty.</exception>
[MethodImpl(InliningOptions.ShortMethod)]
public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
{
if (value is null)
{
ThrowArgumentNullException(parameterName);
}

if (value.Count == 0)
{
ThrowArgumentException("Must not be empty.", parameterName);
}
}

/// <summary>
/// Ensures that the specified value is less than a maximum value.
/// </summary>
Expand Down
10 changes: 3 additions & 7 deletions src/ImageSharp/Formats/Png/Filters/SubFilter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand All @@ -25,12 +25,8 @@ public static void Decode(Span<byte> scanline, int bytesPerPixel)
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);

// Sub(x) + Raw(x-bpp)
int x = 1;
for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
}

int x = bytesPerPixel + 1;
Unsafe.Add(ref scanBaseRef, x);
for (; x < scanline.Length; ++x)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
Expand Down
12 changes: 1 addition & 11 deletions src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -419,16 +419,6 @@ private ushort ReadUInt16()
: default;
}

private string ReadString(int length)
{
if (this.TryReadSpan(length, out ReadOnlySpan<byte> span) && span.Length != 0)
{
return this.ConvertToString(span);
}

return null;
}

private void GetThumbnail(uint offset)
{
var values = new List<ExifValue>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -526,9 +526,8 @@ public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry(
{
int start = this.currentIndex - 8;

// TODO: Why are we storing variable
ushort inChannelCount = this.ReadUInt16();
ushort outChannelCount = this.ReadUInt16();
this.ReadUInt16();
this.ReadUInt16();
uint elementCount = this.ReadUInt32();

var positionTable = new IccPositionNumber[elementCount];
Expand Down Expand Up @@ -902,4 +901,4 @@ public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description);
}
}
}
}
13 changes: 1 addition & 12 deletions src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -83,16 +83,5 @@ private bool GetBit(byte value, int position)
{
return ((value >> (7 - position)) & 1) == 1;
}

/// <summary>
/// Gets the bit value at a specified position
/// </summary>
/// <param name="value">The value from where the bit will be extracted</param>
/// <param name="position">Position of the bit. Zero based index from left to right.</param>
/// <returns>The bit value at specified position</returns>
private bool GetBit(ushort value, int position)
{
return ((value >> (15 - position)) & 1) == 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public int WriteOneDimensionalCurve(IccOneDimensionalCurve value)
public int WriteResponseCurve(IccResponseCurve value)
{
int count = this.WriteUInt32((uint)value.CurveType);
int channels = value.XyzValues.Length;

foreach (IccResponseNumber[] responseArray in value.ResponseArrays)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -37,9 +37,6 @@ public int WriteVersionNumber(in IccVersion value)
int minor = value.Minor.Clamp(0, 15);
int bugfix = value.Patch.Clamp(0, 15);

// TODO: This is not used?
byte mb = (byte)((minor << 4) | bugfix);

int version = (major << 24) | (minor << 20) | (bugfix << 16);
return this.WriteInt32(version);
}
Expand Down
3 changes: 1 addition & 2 deletions src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand All @@ -15,7 +15,6 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial struct Gray16 : IPixel<Gray16>, IPackedVector<ushort>
{
private const float Max = ushort.MaxValue;
private const float Average = 1 / 3F;

/// <summary>
/// Initializes a new instance of the <see cref="Gray16"/> struct.
Expand Down
8 changes: 1 addition & 7 deletions src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand All @@ -16,12 +16,6 @@ public partial struct Gray8 : IPixel<Gray8>, IPackedVector<byte>
{
private static readonly Vector4 MaxBytes = new Vector4(255F);
private static readonly Vector4 Half = new Vector4(0.5F);
private const float Average = 1 / 3F;

private static readonly Vector4 Min = new Vector4(0, 0, 0, 1f);
private static readonly Vector4 Max = Vector4.One;

private static readonly Vector4 Accumulator = new Vector4(255f * Average, 255f * Average, 255f * Average, 0.5f);

/// <summary>
/// Initializes a new instance of the <see cref="Gray8"/> struct.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -193,11 +193,10 @@ public bool Equals(RgbaVector other) =>
/// <inheritdoc/>
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
}

/// <inheritdoc/>
public override int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
{
int sourceWidth = source.Width;
int sourceHeight = source.Height;
int numberOfPixels = sourceWidth * sourceHeight;
int tileWidth = (int)MathF.Ceiling(sourceWidth / (float)this.Tiles);
int tileHeight = (int)MathF.Ceiling(sourceHeight / (float)this.Tiles);
int pixelsInTile = tileWidth * tileHeight;
int tileCount = this.Tiles;
int halfTileWidth = tileWidth / 2;
int halfTileHeight = tileHeight / 2;
int luminanceLevels = this.LuminanceLevels;
Expand Down Expand Up @@ -103,8 +102,8 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
float luminanceEqualized = InterpolateBetweenFourTiles(
pixel,
cdfData,
this.Tiles,
this.Tiles,
tileCount,
tileCount,
tileX,
tileY,
cdfX,
Expand Down Expand Up @@ -467,7 +466,6 @@ public void CalculateLookupTables(ImageFrame<TPixel> source, HistogramEqualizati
int tileWidth = this.tileWidth;
int tileHeight = this.tileHeight;
int luminanceLevels = this.luminanceLevels;
MemoryAllocator memoryAllocator = this.memoryAllocator;

Parallel.For(
0,
Expand Down Expand Up @@ -543,4 +541,4 @@ public void Dispose()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public AdaptiveHistogramEqualizationSlidingWindowProcessor(int luminanceLevels,
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
int numberOfPixels = source.Width * source.Height;
Span<TPixel> pixels = source.GetPixelSpan();

var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
int tileWidth = source.Width / this.Tiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
{
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
int numberOfPixels = source.Width * source.Height;
Span<TPixel> pixels = source.GetPixelSpan();
var workingRect = new Rectangle(0, 0, source.Width, source.Height);

using (IMemoryOwner<int> histogramBuffer = memoryAllocator.Allocate<int>(this.LuminanceLevels, AllocationOptions.Clean))
Expand Down Expand Up @@ -104,4 +103,4 @@ ref MemoryMarshal.GetReference(histogram),
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, ImageFrame<TPixe
return;
}

int sourceHeight = source.Height;

PixelConversionModifiers conversionModifiers =
PixelConversionModifiers.Premultiply.ApplyCompanding(this.Compand);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ public void StandardSimdFromInt_RefCast()
int n = Count / Vector<float>.Count;

ref Vector<float> bf = ref Unsafe.As<float, Vector<float>>(ref this.data[0]);
ref Vector<int> bu = ref Unsafe.As<Vector<float>, Vector<int>>(ref bf);

var scale = new Vector<float>(1f / 255f);

for (int i = 0; i < n; i++)
Expand Down
10 changes: 5 additions & 5 deletions tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand Down Expand Up @@ -50,7 +50,7 @@ public void CorrectlySetsBrushAndPath()
ShapePath region = Assert.IsType<ShapePath>(processor.Region);

// path is converted to a polygon before filling
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);

Assert.Equal(this.pen.StrokeFill, processor.Brush);
}
Expand All @@ -68,7 +68,7 @@ public void CorrectlySetsBrushPathOptions()
Assert.Equal(this.noneDefault, processor.Options);

ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);

Assert.Equal(this.pen.StrokeFill, processor.Brush);
}
Expand All @@ -86,7 +86,7 @@ public void CorrectlySetsColorAndPath()
Assert.Equal(GraphicsOptions.Default, processor.Options);

ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);

SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
Expand All @@ -105,7 +105,7 @@ public void CorrectlySetsColorPathAndOptions()
Assert.Equal(this.noneDefault, processor.Options);

ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);

SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
Expand Down
Loading