• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marthijn / Sidio.OpenGraph / 17148719873

22 Aug 2025 07:11AM UTC coverage: 93.299% (-0.2%) from 93.514%
17148719873

push

github

marthijn
⚡️ Fixed shared object pool

28 of 28 branches covered (100.0%)

Branch coverage included in aggregate %.

13 of 14 new or added lines in 4 files covered. (92.86%)

153 of 166 relevant lines covered (92.17%)

52.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/Sidio.OpenGraph/ObjectPooling/StringBuilderPolicy.cs
1
using System.Text;
2
using Microsoft.Extensions.ObjectPool;
3

4
namespace Sidio.OpenGraph.ObjectPooling;
5

6
internal sealed class StringBuilderPolicy : PooledObjectPolicy<StringBuilder>
7
{
8
    private readonly int _initialCapacity;
9
    private readonly int _maxRetainedCapacity;
10

11
    public StringBuilderPolicy(int initialCapacity = 256, int maxRetainedCapacity = 1024)
5✔
12
    {
13
        _initialCapacity = initialCapacity;
5✔
14
        _maxRetainedCapacity = maxRetainedCapacity;
5✔
15
    }
5✔
16

17
    public override StringBuilder Create() => new (_initialCapacity);
5✔
18

19
    public override bool Return(StringBuilder sb)
20
    {
21
        if (sb.Capacity > _maxRetainedCapacity)
21✔
22
        {
23
            // too big, discard it and let GC collect it
NEW
24
            return false;
×
25
        }
26

27
        sb.Clear(); // reset contents for next caller
21✔
28
        return true;
21✔
29
    }
30
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc