Initial commit.
This commit is contained in:
1 parent
e5b0fea18c
commit
9f35f6c558
94 files changed
+12857
No files matched your search
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
|
||||
namespace PerfectNumbers.Core;
|
||||
|
||||
public static class StringBuilderPool
|
||||
{
|
||||
private static readonly ConcurrentQueue<StringBuilder> _stringBuilderPool = new();
|
||||
|
||||
public static StringBuilder Rent() => _stringBuilderPool.TryDequeue(out var sb) ? sb : new();
|
||||
|
||||
public static void Return(StringBuilder sb)
|
||||
{
|
||||
_ = sb.Clear();
|
||||
_stringBuilderPool.Enqueue(sb);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user