Skip to content

Commit 981f0e2

Browse files
committed
In JavaScriptEngineSwitcher.ChakraCore no longer performed cleaning of reused buffers when returning to the pool
1 parent 4838dcd commit 981f0e2

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsPropertyId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public string Name
7171
}
7272
finally
7373
{
74-
byteArrayPool.Return(buffer, true);
74+
byteArrayPool.Return(buffer);
7575
}
7676

7777
return name;

src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ public int ToInt32()
746746
}
747747
finally
748748
{
749-
charArrayPool.Return(buffer, true);
749+
charArrayPool.Return(buffer);
750750
}
751751
}
752752
else
@@ -771,7 +771,7 @@ public int ToInt32()
771771
}
772772
finally
773773
{
774-
byteArrayPool.Return(buffer, true);
774+
byteArrayPool.Return(buffer);
775775
}
776776
}
777777

src/JavaScriptEngineSwitcher.ChakraCore/Polyfills/System/Buffers/ArrayPool.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ private static ArrayPool<T> EnsureSharedCreated()
8787
/// if it's determined that the pool already has enough buffers stored.
8888
/// </remarks>
8989
/// <param name="array">The buffer previously obtained from <see cref="Rent"/> to return to the pool</param>
90-
/// <param name="clearArray">If <c>true</c> and if the pool will store the buffer to enable subsequent
91-
/// reuse, <see cref="Return"/> will clear <paramref name="array"/> of its contents so that a subsequent
92-
/// consumer via <see cref="Rent"/> will not see the previous consumer's content. If <c>false</c> or
93-
/// if the pool will release the buffer, the array's contents are left unchanged.</param>
94-
public abstract void Return(T[] array, bool clearArray = false);
90+
public abstract void Return(T[] array);
9591
}
9692
}
9793
#endif

src/JavaScriptEngineSwitcher.ChakraCore/Polyfills/System/Buffers/DefaultArrayPool.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public override T[] Rent(int minimumLength)
125125
return buffer;
126126
}
127127

128-
public override void Return(T[] array, bool clearArray = false)
128+
public override void Return(T[] array)
129129
{
130130
if (array == null)
131131
{
@@ -144,12 +144,6 @@ public override void Return(T[] array, bool clearArray = false)
144144
// If we can tell that the buffer was allocated, drop it. Otherwise, check if we have space in the pool
145145
if (bucket < _buckets.Length)
146146
{
147-
// Clear the array if the user requests
148-
if (clearArray)
149-
{
150-
Array.Clear(array, 0, array.Length);
151-
}
152-
153147
// Return the buffer to its bucket. In the future, we might consider having Return return false
154148
// instead of dropping a bucket, in which case we could try to return to a lower-sized bucket,
155149
// just as how in Rent we allow renting from a higher-sized bucket.

0 commit comments

Comments
 (0)