-Fixed JSON string encoder not getting buffer from buffer pool

This commit is contained in:
James Newton-King
2016-03-09 16:34:02 +13:00
parent 443462f9f2
commit 5ddbc508f0
5 changed files with 50 additions and 20 deletions
+19 -17
View File
@@ -609,23 +609,25 @@ namespace Newtonsoft.Json.Tests
Assert.AreEqual(4, value.Count);
}
public class JsonArrayPool : IArrayPool<char>
{
public static readonly JsonArrayPool Instance = new JsonArrayPool();
public char[] Rent(int minimumLength)
{
// use System.Buffers shared pool
return ArrayPool<char>.Shared.Rent(minimumLength);
}
public void Return(char[] array)
{
// use System.Buffers shared pool
ArrayPool<char>.Shared.Return(array);
}
}
#endif
}
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
public class JsonArrayPool : IArrayPool<char>
{
public static readonly JsonArrayPool Instance = new JsonArrayPool();
public char[] Rent(int minimumLength)
{
// use System.Buffers shared pool
return ArrayPool<char>.Shared.Rent(minimumLength);
}
public void Return(char[] array)
{
// use System.Buffers shared pool
ArrayPool<char>.Shared.Return(array);
}
}
#endif
}