Skip to content

Commit

Permalink
Fix CappedArrayPool : 1. alloc new array without caching 2. some cach…
Browse files Browse the repository at this point in the history
…ed array is not be used
  • Loading branch information
Ruoh3kou committed May 13, 2024
1 parent 5861081 commit 2695c6c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal CappedArrayPool(int maxLength)
{
buckets[i][j] = new T[arrayLength];
}
tails[i] = buckets[i].Length - 1;
tails[i] = 0;
}
}

Expand All @@ -48,7 +48,12 @@ public T[] Rent(int length)
buckets[i] = bucket;
}

var result = bucket[tail] ?? new T[length];
if (bucket[tail] == null)
{
bucket[tail] = new T[length];
}

var result = bucket[tail];
tails[i] += 1;
return result;
}
Expand Down

0 comments on commit 2695c6c

Please sign in to comment.