< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 46
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%110%
.ctor(...)100%110%
GetInstance()100%110%
AllocateChunk(...)0%220%
FreeChunk()100%110%
Free()100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PooledBlobBuilder.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Reflection.Internal;
 5
 6namespace System.Reflection.Metadata
 7{
 8    internal sealed class PooledBlobBuilder : BlobBuilder
 9    {
 10        private const int PoolSize = 128;
 11        private const int ChunkSize = 1024;
 12
 013        private static readonly ObjectPool<PooledBlobBuilder> s_chunkPool = new ObjectPool<PooledBlobBuilder>(() => new 
 14
 15        private PooledBlobBuilder(int size)
 016            : base(size)
 017        {
 018        }
 19
 20        public static PooledBlobBuilder GetInstance()
 021        {
 022            return s_chunkPool.Allocate();
 023        }
 24
 25        protected override BlobBuilder AllocateChunk(int minimalSize)
 026        {
 027            if (minimalSize <= ChunkSize)
 028            {
 029                return s_chunkPool.Allocate();
 30            }
 31
 032            return new BlobBuilder(minimalSize);
 033        }
 34
 35        protected override void FreeChunk()
 036        {
 037            s_chunkPool.Free(this);
 038        }
 39
 40        public new void Free()
 041        {
 042            base.Free();
 043        }
 44    }
 45}
 46