1
1
// Copyright (c) Six Labors.
2
2
// Licensed under the Six Labors Split License.
3
- #nullable disable
4
3
5
4
using System . Buffers ;
6
5
using SixLabors . ImageSharp . Memory ;
@@ -14,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless;
14
13
/// </summary>
15
14
internal sealed class CostManager : IDisposable
16
15
{
17
- private CostInterval head ;
16
+ private CostInterval ? head ;
18
17
19
18
private const int FreeIntervalsStartCount = 25 ;
20
19
@@ -103,10 +102,10 @@ public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner<ushort> distArr
103
102
/// <param name="doCleanIntervals">If 'doCleanIntervals' is true, intervals that end before 'i' will be popped.</param>
104
103
public void UpdateCostAtIndex ( int i , bool doCleanIntervals )
105
104
{
106
- CostInterval current = this . head ;
105
+ CostInterval ? current = this . head ;
107
106
while ( current != null && current . Start <= i )
108
107
{
109
- CostInterval next = current . Next ;
108
+ CostInterval ? next = current . Next ;
110
109
if ( current . End <= i )
111
110
{
112
111
if ( doCleanIntervals )
@@ -155,15 +154,15 @@ public void PushInterval(double distanceCost, int position, int len)
155
154
return ;
156
155
}
157
156
158
- CostInterval interval = this . head ;
157
+ CostInterval ? interval = this . head ;
159
158
for ( int i = 0 ; i < this . CacheIntervalsSize && this . CacheIntervals [ i ] . Start < len ; i ++ )
160
159
{
161
160
// Define the intersection of the ith interval with the new one.
162
161
int start = position + this . CacheIntervals [ i ] . Start ;
163
162
int end = position + ( this . CacheIntervals [ i ] . End > len ? len : this . CacheIntervals [ i ] . End ) ;
164
163
float cost = ( float ) ( distanceCost + this . CacheIntervals [ i ] . Cost ) ;
165
164
166
- CostInterval intervalNext ;
165
+ CostInterval ? intervalNext ;
167
166
for ( ; interval != null && interval . Start < end ; interval = intervalNext )
168
167
{
169
168
intervalNext = interval . Next ;
@@ -225,7 +224,7 @@ public void PushInterval(double distanceCost, int position, int len)
225
224
/// Pop an interval from the manager.
226
225
/// </summary>
227
226
/// <param name="interval">The interval to remove.</param>
228
- private void PopInterval ( CostInterval interval )
227
+ private void PopInterval ( CostInterval ? interval )
229
228
{
230
229
if ( interval == null )
231
230
{
@@ -240,7 +239,7 @@ private void PopInterval(CostInterval interval)
240
239
this . freeIntervals . Push ( interval ) ;
241
240
}
242
241
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 )
244
243
{
245
244
if ( start >= end )
246
245
{
@@ -271,7 +270,7 @@ private void InsertInterval(CostInterval intervalIn, float cost, int position, i
271
270
/// it was orphaned (which can be NULL), set it at the right place in the list
272
271
/// of intervals using the start_ ordering and the previous interval as a hint.
273
272
/// </summary>
274
- private void PositionOrphanInterval ( CostInterval current , CostInterval previous )
273
+ private void PositionOrphanInterval ( CostInterval current , CostInterval ? previous )
275
274
{
276
275
previous ??= this . head ;
277
276
@@ -292,7 +291,7 @@ private void PositionOrphanInterval(CostInterval current, CostInterval previous)
292
291
/// <summary>
293
292
/// Given two intervals, make 'prev' be the previous one of 'next' in 'manager'.
294
293
/// </summary>
295
- private void ConnectIntervals ( CostInterval prev , CostInterval next )
294
+ private void ConnectIntervals ( CostInterval ? prev , CostInterval ? next )
296
295
{
297
296
if ( prev != null )
298
297
{
0 commit comments