Skip to content

Commit 6f11341

Browse files
SimonCroppJimBobSquarePants
authored andcommitted
Cleanup (#965)
* redundant () * redundant stirng interpolation * use method groups * redundant unsafe * redundant qualifiers * redundant () * redundant init * redundant init * redundant casts * redundant casts
1 parent b238317 commit 6f11341

File tree

76 files changed

+252
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+252
-252
lines changed

src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
9494
}
9595

9696
float yPlusOne = y + 1;
97-
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction)
97+
for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction)
9898
{
9999
int pointsFound = region.Scan(subPixel + offset, buffer, configuration);
100100
if (pointsFound == 0)
@@ -192,4 +192,4 @@ private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush)
192192
return this.definition.Options.IsOpaqueColorWithoutBlending(solidBrush.Color);
193193
}
194194
}
195-
}
195+
}

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,22 @@ private class CachingGlyphRenderer : IGlyphRenderer, IDisposable
135135

136136
private readonly PathBuilder builder;
137137

138-
private Point currentRenderPosition = default;
139-
private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams = default;
140-
private readonly int offset = 0;
141-
private PointF currentPoint = default(PointF);
138+
private Point currentRenderPosition;
139+
private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams;
140+
private readonly int offset;
141+
private PointF currentPoint;
142142

143143
private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>
144144
glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>();
145145

146-
private readonly bool renderOutline = false;
147-
private readonly bool renderFill = false;
148-
private bool rasterizationRequired = false;
146+
private readonly bool renderOutline;
147+
private readonly bool renderFill;
148+
private bool rasterizationRequired;
149149

150150
public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill)
151151
{
152152
this.MemoryAllocator = memoryAllocator;
153+
this.currentRenderPosition = default;
153154
this.Pen = pen;
154155
this.renderFill = renderFill;
155156
this.renderOutline = pen != null;
@@ -326,7 +327,7 @@ private Buffer2D<float> Render(IPath path)
326327
bool scanlineDirty = false;
327328
float yPlusOne = y + 1;
328329

329-
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction)
330+
for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction)
330331
{
331332
var start = new PointF(path.Bounds.Left - 1, subPixel);
332333
var end = new PointF(path.Bounds.Right + 1, subPixel);

src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Threading.Tasks;
@@ -16,7 +16,7 @@ internal static class ConfigurationExtensions
1616
/// </summary>
1717
public static ParallelOptions GetParallelOptions(this Configuration configuration)
1818
{
19-
return new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
19+
return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
2020
}
2121
}
22-
}
22+
}

src/ImageSharp/Common/Helpers/Guard.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static void DestinationShouldNotBeTooShort<TSource, TDest>(
231231
{
232232
if (destination.Length < source.Length)
233233
{
234-
ThrowArgumentException($"Destination span is too short!", destinationParamName);
234+
ThrowArgumentException("Destination span is too short!", destinationParamName);
235235
}
236236
}
237237

@@ -251,7 +251,7 @@ public static void DestinationShouldNotBeTooShort<TSource, TDest>(
251251
{
252252
if (destination.Length < source.Length)
253253
{
254-
ThrowArgumentException($"Destination span is too short!", destinationParamName);
254+
ThrowArgumentException("Destination span is too short!", destinationParamName);
255255
}
256256
}
257257

src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -61,7 +61,7 @@ public static void IterateRows(
6161

6262
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
6363

64-
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps };
64+
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
6565

6666
Parallel.For(
6767
0,
@@ -109,7 +109,7 @@ public static void IterateRowsWithTempBuffer<T>(
109109

110110
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
111111

112-
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps };
112+
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
113113

114114
Parallel.For(
115115
0,
@@ -158,4 +158,4 @@ private static void ValidateRectangle(Rectangle rectangle)
158158
$"{nameof(rectangle)}.{nameof(rectangle.Height)}");
159159
}
160160
}
161-
}
161+
}

src/ImageSharp/Formats/Bmp/BmpFileHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static BmpFileHeader Parse(Span<byte> data)
6262
return MemoryMarshal.Cast<byte, BmpFileHeader>(data)[0];
6363
}
6464

65-
public unsafe void WriteTo(Span<byte> buffer)
65+
public void WriteTo(Span<byte> buffer)
6666
{
6767
ref BmpFileHeader dest = ref Unsafe.As<byte, BmpFileHeader>(ref MemoryMarshal.GetReference(buffer));
6868

src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public void WriteV3Header(Span<byte> buffer)
447447
/// Writes a complete Bitmap V4 header to a buffer.
448448
/// </summary>
449449
/// <param name="buffer">The buffer to write to.</param>
450-
public unsafe void WriteV4Header(Span<byte> buffer)
450+
public void WriteV4Header(Span<byte> buffer)
451451
{
452452
ref BmpInfoHeader dest = ref Unsafe.As<byte, BmpInfoHeader>(ref MemoryMarshal.GetReference(buffer));
453453

src/ImageSharp/Formats/Gif/GifEncoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
8484
bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;
8585

8686
// Quantize the image returning a palette.
87-
IQuantizedFrame<TPixel> quantized = null;
87+
IQuantizedFrame<TPixel> quantized;
8888
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration()))
8989
{
9090
quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void ParseBaselineData()
124124
}
125125
}
126126

127-
private unsafe void ParseBaselineDataInterleaved()
127+
private void ParseBaselineDataInterleaved()
128128
{
129129
// Interleaved
130130
int mcu = 0;
@@ -196,7 +196,7 @@ ref Unsafe.Add(ref blockRef, blockCol),
196196
}
197197
}
198198

199-
private unsafe void ParseBaselineDataNonInterleaved()
199+
private void ParseBaselineDataNonInterleaved()
200200
{
201201
JpegComponent component = this.components[this.frame.ComponentOrder[0]];
202202
ref HuffmanScanBuffer buffer = ref this.scanBuffer;
@@ -366,7 +366,7 @@ ref Unsafe.Add(ref blockRef, blockCol),
366366
}
367367
}
368368

369-
private unsafe void ParseProgressiveDataNonInterleaved()
369+
private void ParseProgressiveDataNonInterleaved()
370370
{
371371
JpegComponent component = this.components[this.frame.ComponentOrder[0]];
372372
ref HuffmanScanBuffer buffer = ref this.scanBuffer;

src/ImageSharp/Formats/Png/PngConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal static class PngConstants
5959
/// <summary>
6060
/// The dictionary of available color types.
6161
/// </summary>
62-
public static readonly Dictionary<PngColorType, byte[]> ColorTypes = new Dictionary<PngColorType, byte[]>()
62+
public static readonly Dictionary<PngColorType, byte[]> ColorTypes = new Dictionary<PngColorType, byte[]>
6363
{
6464
[PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 },
6565
[PngColorType.Rgb] = new byte[] { 8, 16 },

0 commit comments

Comments
 (0)