Skip to content

Commit f115c16

Browse files
SimonCroppJimBobSquarePants
authored andcommitted
remove some redundant variables and type params (#971)
* remove redundant variable init * redundant variables * remove redundant tileY variable * remove redundant sum variable * redundant mcu variable * redundant type params * Revert "remove redundant sum variable" This reverts commit 21de86c.
1 parent 2909994 commit f115c16

File tree

5 files changed

+10
-29
lines changed

5 files changed

+10
-29
lines changed

src/ImageSharp/Advanced/AotCompilerTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static void AotCompileDithering<TPixel>()
133133
{
134134
var test = new FloydSteinbergDiffuser();
135135
TPixel pixel = default;
136-
test.Dither<TPixel>(new ImageFrame<TPixel>(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0);
136+
test.Dither(new ImageFrame<TPixel>(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0);
137137
}
138138

139139
/// <summary>

src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ private void ParseBaselineDataNonInterleaved()
209209
dcHuffmanTable.Configure();
210210
acHuffmanTable.Configure();
211211

212-
int mcu = 0;
213212
for (int j = 0; j < h; j++)
214213
{
215214
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@@ -228,9 +227,6 @@ ref Unsafe.Add(ref blockRef, i),
228227
ref dcHuffmanTable,
229228
ref acHuffmanTable);
230229

231-
// Every data block is an MCU, so countdown the restart interval
232-
mcu++;
233-
234230
this.HandleRestart();
235231
}
236232
}
@@ -379,7 +375,6 @@ private void ParseProgressiveDataNonInterleaved()
379375
ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DCHuffmanTableId];
380376
dcHuffmanTable.Configure();
381377

382-
int mcu = 0;
383378
for (int j = 0; j < h; j++)
384379
{
385380
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@@ -397,8 +392,6 @@ private void ParseProgressiveDataNonInterleaved()
397392
ref Unsafe.Add(ref blockRef, i),
398393
ref dcHuffmanTable);
399394

400-
// Every data block is an MCU, so countdown the restart interval
401-
mcu++;
402395
this.HandleRestart();
403396
}
404397
}
@@ -408,7 +401,6 @@ ref Unsafe.Add(ref blockRef, i),
408401
ref HuffmanTable acHuffmanTable = ref this.acHuffmanTables[component.ACHuffmanTableId];
409402
acHuffmanTable.Configure();
410403

411-
int mcu = 0;
412404
for (int j = 0; j < h; j++)
413405
{
414406
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@@ -425,8 +417,6 @@ ref Unsafe.Add(ref blockRef, i),
425417
ref Unsafe.Add(ref blockRef, i),
426418
ref acHuffmanTable);
427419

428-
// Every data block is an MCU, so countdown the restart interval
429-
mcu++;
430420
this.HandleRestart();
431421
}
432422
}

src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,22 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
7777
new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism },
7878
index =>
7979
{
80-
int cdfX = 0;
81-
int tileX = 0;
82-
int tileY = 0;
8380
int y = tileYStartPositions[index].y;
8481
int cdfYY = tileYStartPositions[index].cdfY;
8582

8683
// It's unfortunate that we have to do this per iteration.
8784
ref TPixel sourceBase = ref source.GetPixelReference(0, 0);
8885

89-
cdfX = 0;
86+
int cdfX = 0;
9087
for (int x = halfTileWidth; x < sourceWidth - halfTileWidth; x += tileWidth)
9188
{
92-
tileY = 0;
89+
int tileY = 0;
9390
int yEnd = Math.Min(y + tileHeight, sourceHeight);
9491
int xEnd = Math.Min(x + tileWidth, sourceWidth);
9592
for (int dy = y; dy < yEnd; dy++)
9693
{
9794
int dyOffSet = dy * sourceWidth;
98-
tileX = 0;
95+
int tileX = 0;
9996
for (int dx = x; dx < xEnd; dx++)
10097
{
10198
ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx);
@@ -221,7 +218,6 @@ private static void ProcessBorderColumn(
221218
int xEnd,
222219
int luminanceLevels)
223220
{
224-
int halfTileWidth = tileWidth / 2;
225221
int halfTileHeight = tileHeight / 2;
226222

227223
int cdfY = 0;
@@ -232,13 +228,11 @@ private static void ProcessBorderColumn(
232228
for (int dy = y; dy < yLimit; dy++)
233229
{
234230
int dyOffSet = dy * sourceWidth;
235-
int tileX = halfTileWidth;
236231
for (int dx = xStart; dx < xEnd; dx++)
237232
{
238233
ref TPixel pixel = ref Unsafe.Add(ref pixelBase, dyOffSet + dx);
239234
float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels);
240235
pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W));
241-
tileX++;
242236
}
243237

244238
tileY++;
@@ -277,7 +271,6 @@ private static void ProcessBorderRow(
277271
int cdfX = 0;
278272
for (int x = halfTileWidth; x < sourceWidth - halfTileWidth; x += tileWidth)
279273
{
280-
int tileY = 0;
281274
for (int dy = yStart; dy < yEnd; dy++)
282275
{
283276
int dyOffSet = dy * sourceWidth;
@@ -290,8 +283,6 @@ private static void ProcessBorderRow(
290283
pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W));
291284
tileX++;
292285
}
293-
294-
tileY++;
295286
}
296287

297288
cdfX++;

tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void NonMutatingEncodePreservesPaletteCount()
150150
outStream.Position = 0;
151151
var clone = Image.Load<Rgba32>(outStream);
152152

153-
GifMetadata cloneMetaData = clone.Metadata.GetFormatMetadata<GifMetadata>(GifFormat.Instance);
153+
GifMetadata cloneMetaData = clone.Metadata.GetFormatMetadata(GifFormat.Instance);
154154
Assert.Equal(metaData.ColorTableMode, cloneMetaData.ColorTableMode);
155155

156156
// Gifiddle and Cyotek GifInfo say this image has 64 colors.

tests/ImageSharp.Tests/Image/ImageSaveTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void SavePath()
5252
this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream);
5353
this.Image.Save("path.png");
5454

55-
this.encoder.Verify(x => x.Encode<Rgba32>(this.Image, stream));
55+
this.encoder.Verify(x => x.Encode(this.Image, stream));
5656
}
5757

5858

@@ -64,15 +64,15 @@ public void SavePathWithEncoder()
6464

6565
this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
6666

67-
this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(this.Image, stream));
67+
this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream));
6868
}
6969

7070
[Fact]
7171
public void ToBase64String()
7272
{
7373
string str = this.Image.ToBase64String(this.localImageFormat.Object);
7474

75-
this.encoder.Verify(x => x.Encode<Rgba32>(this.Image, It.IsAny<Stream>()));
75+
this.encoder.Verify(x => x.Encode(this.Image, It.IsAny<Stream>()));
7676
}
7777

7878
[Fact]
@@ -81,7 +81,7 @@ public void SaveStreamWithMime()
8181
Stream stream = new MemoryStream();
8282
this.Image.Save(stream, this.localImageFormat.Object);
8383

84-
this.encoder.Verify(x => x.Encode<Rgba32>(this.Image, stream));
84+
this.encoder.Verify(x => x.Encode(this.Image, stream));
8585
}
8686

8787
[Fact]
@@ -91,7 +91,7 @@ public void SaveStreamWithEncoder()
9191

9292
this.Image.Save(stream, this.encoderNotInFormat.Object);
9393

94-
this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(this.Image, stream));
94+
this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream));
9595
}
9696

9797
public void Dispose()

0 commit comments

Comments
 (0)