Skip to content

Commit a27df8a

Browse files
committed
Remove nullable disable from CostManager and CostInterval
1 parent d9f7278 commit a27df8a

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/ImageSharp/Formats/Webp/Lossless/CostInterval.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3-
#nullable disable
43

54
using System.Diagnostics;
65

@@ -33,7 +32,7 @@ internal class CostInterval
3332

3433
public int Index { get; set; }
3534

36-
public CostInterval Previous { get; set; }
35+
public CostInterval? Previous { get; set; }
3736

38-
public CostInterval Next { get; set; }
37+
public CostInterval? Next { get; set; }
3938
}

src/ImageSharp/Formats/Webp/Lossless/CostManager.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3-
#nullable disable
43

54
using System.Buffers;
65
using SixLabors.ImageSharp.Memory;
@@ -14,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless;
1413
/// </summary>
1514
internal sealed class CostManager : IDisposable
1615
{
17-
private CostInterval head;
16+
private CostInterval? head;
1817

1918
private const int FreeIntervalsStartCount = 25;
2019

@@ -103,10 +102,10 @@ public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner<ushort> distArr
103102
/// <param name="doCleanIntervals">If 'doCleanIntervals' is true, intervals that end before 'i' will be popped.</param>
104103
public void UpdateCostAtIndex(int i, bool doCleanIntervals)
105104
{
106-
CostInterval current = this.head;
105+
CostInterval? current = this.head;
107106
while (current != null && current.Start <= i)
108107
{
109-
CostInterval next = current.Next;
108+
CostInterval? next = current.Next;
110109
if (current.End <= i)
111110
{
112111
if (doCleanIntervals)
@@ -155,15 +154,15 @@ public void PushInterval(double distanceCost, int position, int len)
155154
return;
156155
}
157156

158-
CostInterval interval = this.head;
157+
CostInterval? interval = this.head;
159158
for (int i = 0; i < this.CacheIntervalsSize && this.CacheIntervals[i].Start < len; i++)
160159
{
161160
// Define the intersection of the ith interval with the new one.
162161
int start = position + this.CacheIntervals[i].Start;
163162
int end = position + (this.CacheIntervals[i].End > len ? len : this.CacheIntervals[i].End);
164163
float cost = (float)(distanceCost + this.CacheIntervals[i].Cost);
165164

166-
CostInterval intervalNext;
165+
CostInterval? intervalNext;
167166
for (; interval != null && interval.Start < end; interval = intervalNext)
168167
{
169168
intervalNext = interval.Next;
@@ -225,7 +224,7 @@ public void PushInterval(double distanceCost, int position, int len)
225224
/// Pop an interval from the manager.
226225
/// </summary>
227226
/// <param name="interval">The interval to remove.</param>
228-
private void PopInterval(CostInterval interval)
227+
private void PopInterval(CostInterval? interval)
229228
{
230229
if (interval == null)
231230
{
@@ -240,7 +239,7 @@ private void PopInterval(CostInterval interval)
240239
this.freeIntervals.Push(interval);
241240
}
242241

243-
private void InsertInterval(CostInterval intervalIn, float cost, int position, int start, int end)
242+
private void InsertInterval(CostInterval? intervalIn, float cost, int position, int start, int end)
244243
{
245244
if (start >= end)
246245
{
@@ -271,7 +270,7 @@ private void InsertInterval(CostInterval intervalIn, float cost, int position, i
271270
/// it was orphaned (which can be NULL), set it at the right place in the list
272271
/// of intervals using the start_ ordering and the previous interval as a hint.
273272
/// </summary>
274-
private void PositionOrphanInterval(CostInterval current, CostInterval previous)
273+
private void PositionOrphanInterval(CostInterval current, CostInterval? previous)
275274
{
276275
previous ??= this.head;
277276

@@ -292,7 +291,7 @@ private void PositionOrphanInterval(CostInterval current, CostInterval previous)
292291
/// <summary>
293292
/// Given two intervals, make 'prev' be the previous one of 'next' in 'manager'.
294293
/// </summary>
295-
private void ConnectIntervals(CostInterval prev, CostInterval next)
294+
private void ConnectIntervals(CostInterval? prev, CostInterval? next)
296295
{
297296
if (prev != null)
298297
{

0 commit comments

Comments
 (0)