Skip to content

Commit

Permalink
Merge pull request #666 from Ruoh3kou/fix_cappedArrayPool
Browse files Browse the repository at this point in the history
Fix CappedArrayPool some bug
  • Loading branch information
hadashiA authored May 14, 2024
2 parents 5861081 + 2695c6c commit b82cd29
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 b82cd29

Please sign in to comment.