-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistently use CharArrayPool in JsonWriter to cut cost of initializ…
…ing char arrays
- Loading branch information
John Gathogo
committed
May 20, 2021
1 parent
9449c28
commit 8c5d640
Showing
5 changed files
with
105 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/FunctionalTests/Microsoft.OData.Core.Tests/Json/MockCharArrayPool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//--------------------------------------------------------------------- | ||
// <copyright file="MockCharArrayPool.cs" company="Microsoft"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | ||
// </copyright> | ||
//--------------------------------------------------------------------- | ||
|
||
using System; | ||
using Microsoft.OData.Buffers; | ||
|
||
namespace Microsoft.OData.Tests.Json | ||
{ | ||
public class MockCharArrayPool : ICharArrayPool | ||
{ | ||
public Action<int> RentVerifier; | ||
public Action<char[]> ReturnVerifier; | ||
|
||
public char[] Rent(int minSize) | ||
{ | ||
var charArray = new char[minSize]; | ||
RentVerifier(minSize); | ||
|
||
return charArray; | ||
} | ||
|
||
public void Return(char[] array) | ||
{ | ||
ReturnVerifier(array); | ||
// Do nothing else | ||
} | ||
} | ||
} |