Skip to content

Commit 7847fab

Browse files
committed
Remove ? for pixelMap and paletteOwner
1 parent e7bcc5f commit 7847fab

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
2626
private readonly int maxColors;
2727
private readonly int bitDepth;
2828
private readonly Octree octree;
29-
private IMemoryOwner<TPixel>? paletteOwner;
29+
private IMemoryOwner<TPixel> paletteOwner;
3030
private ReadOnlyMemory<TPixel> palette;
3131
private EuclideanPixelMap<TPixel>? pixelMap;
3232
private readonly bool isDithering;
@@ -98,7 +98,7 @@ public void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
9898
}
9999

100100
int paletteIndex = 0;
101-
Span<TPixel> paletteSpan = this.paletteOwner!.GetSpan();
101+
Span<TPixel> paletteSpan = this.paletteOwner.GetSpan();
102102

103103
// On very rare occasions, (blur.png), the quantizer does not preserve a
104104
// transparent entry when palletizing the captured colors.
@@ -112,7 +112,7 @@ public void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
112112
}
113113

114114
this.octree.Palletize(paletteSpan, max, ref paletteIndex);
115-
ReadOnlyMemory<TPixel> result = this.paletteOwner!.Memory[..paletteSpan.Length];
115+
ReadOnlyMemory<TPixel> result = this.paletteOwner.Memory[..paletteSpan.Length];
116116

117117
// When called multiple times by QuantizerUtilities.BuildPalette
118118
// this prevents memory churn caused by reallocation.
@@ -157,8 +157,7 @@ public void Dispose()
157157
if (!this.isDisposed)
158158
{
159159
this.isDisposed = true;
160-
this.paletteOwner?.Dispose();
161-
this.paletteOwner = null;
160+
this.paletteOwner.Dispose();
162161
this.pixelMap?.Dispose();
163162
this.pixelMap = null;
164163
}

src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization;
2020
internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
2121
where TPixel : unmanaged, IPixel<TPixel>
2222
{
23-
private EuclideanPixelMap<TPixel>? pixelMap;
23+
private EuclideanPixelMap<TPixel> pixelMap;
2424

2525
/// <summary>
2626
/// Initializes a new instance of the <see cref="PaletteQuantizer{TPixel}"/> struct.
@@ -46,7 +46,7 @@ public PaletteQuantizer(Configuration configuration, QuantizerOptions options, R
4646
public QuantizerOptions Options { get; }
4747

4848
/// <inheritdoc/>
49-
public ReadOnlyMemory<TPixel> Palette => this.pixelMap!.Palette;
49+
public ReadOnlyMemory<TPixel> Palette => this.pixelMap.Palette;
5050

5151
/// <inheritdoc/>
5252
[MethodImpl(InliningOptions.ShortMethod)]
@@ -62,12 +62,11 @@ public void AddPaletteColors(Buffer2DRegion<TPixel> pixelRegion)
6262
/// <inheritdoc/>
6363
[MethodImpl(InliningOptions.ShortMethod)]
6464
public readonly byte GetQuantizedColor(TPixel color, out TPixel match)
65-
=> (byte)this.pixelMap!.GetClosestColor(color, out match);
65+
=> (byte)this.pixelMap.GetClosestColor(color, out match);
6666

6767
/// <inheritdoc/>
6868
public void Dispose()
6969
{
70-
this.pixelMap?.Dispose();
71-
this.pixelMap = null;
70+
this.pixelMap.Dispose();
7271
}
7372
}

0 commit comments

Comments
 (0)