Skip to content

Commit 8617eeb

Browse files
committed
Extract constants
1 parent a14c197 commit 8617eeb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

LLama/Common/FixedSizeQueue.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class FixedSizeQueue<T>
1616
private int _count;
1717
private T[]? _window;
1818

19+
private const int MinimumWindowSize = 4;
20+
private const int WindowGrowthFactor = 2;
21+
1922
/// <inheritdoc />
2023
public T this[int index]
2124
{
@@ -133,10 +136,10 @@ internal ReadOnlySpan<T> AsSpan(int count)
133136
return new ReadOnlySpan<T>(_buffer, start, count);
134137
}
135138

136-
_window ??= new T[Math.Min(Capacity, Math.Max(4, count))];
139+
_window ??= new T[Math.Min(Capacity, Math.Max(MinimumWindowSize, count))];
137140
if (_window.Length < count)
138141
{
139-
Array.Resize(ref _window, Math.Min(Capacity, Math.Max(_window.Length * 2, count)));
142+
Array.Resize(ref _window, Math.Min(Capacity, Math.Max(_window.Length * WindowGrowthFactor, count)));
140143
}
141144

142145
var firstSegmentLength = Capacity - start;

0 commit comments

Comments
 (0)